Electronic structure and spectroscopy of the ground and excited states of the HMgO and HMgS radicals