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