According to the law of conservation of mass, the total mass of reactants is equal to the total mass of products.
For,
X + Y → Z2 g 4 g u g
Mass of Z = Mass of X + Mass of Y
⇒ u = (2+4) g = 6 g
Similarly for,
Z + A→ Bu g 7 g c g
Mass of B = Mass of A + Mass of Z
⇒ c = (u + 7) g = (6 + 7) g = 13 g.
Hence, the mass of Z= 6 g and mass of B = 13 g.