Excitonic states in pure and impurity-doped magnesium oxide