Using Gauss's law:
ϕ=ϵ0Qin
Charge 2q is at vertex A of the cube. A vertex is shared by 8 cubes, so the flux contribution from 2q through this cube is 8ϵ02q=4ϵ0q.
Charge q is at the centre of face CDEF. A face center is shared by 2 cubes, so the flux contribution from q through this cube is 2ϵ0q.
Total flux:
ϕ=ϵ0q/4+q/2=4ϵ03q
