Why does the mass increase in this question?
The reason that dialysis bag A and B will get heavier is due to water diffusing into the bags in order to bring the sugar concentration on both sides of the membrane to an equilibrium. Likewise bag C and D will get lighter as water will diffuse out of the bags in order to bring the system as close as possible to equilibrium. Water diffusion is also called osmosis and can be studied closer here: https://en.m.wikipedia.org/wiki/Osmosis