Since ggg is applied first for the composite function fgfgfg, the domain of fgfgfg is the domain of ggg.
Dfg=DgD_{fg} = D_gDfg=Dg Dgf=DfD_{gf} = D_fDgf=Df