What happens when magnesium reacts with water?