Write the balanced chemical equation when X is dissolved in water

A magnesium ribbon is burnt in oxygen to give a white compound X accompanied by emission of light. If the burning ribbon is now placed in an atmosphere of nitrogen, it continues to burn and forms a compound Y.
(i) Write the chemical formulae of X and Y.
(ii) Write the balanced chemical equation when X is dissolved in water.
Answer:
image