Molecular mass of X + O + H=40
→X+16+1=40
→X=23
Only Na has the molecular mass of 23. Therefore, X is sodium and Y is sodium hydroxide as it has molecular mass 40.
Sodium on reaction with cold water gives out sodium hydroxide, hydrogen gas and heat energy. The reaction occurs as follows:
2Na(s)+2H2O(cold)→2NaOH(aq)+H2(g)+Heat energy
Hydrogen gas easily catches fire. Therefore, Z is hydrogen gas.