A metal carbonate X on heating with an acid gives a gas which when passed through a solution Y gives the carbonate back

A metal carbonate X on heating with an acid gives a gas which when passed through a solution Y gives the carbonate back. On the other hand, a gas G that is obtained at anode during electrolysis of brine is passed on dry Y, it gives a compound Z, used for disinfecting drinking water. Identify X, Y, G and Z.

X is calcium carbonate (CaCO3).
Yis slaked lime [Ca(OH)2].
G is chlorine (Cl2) gas.
Z is bleaching powder (CaOCl2).
The reactions involved are: