Preference for bridging versus terminal ligands in magnesium dimers