A systematic, first-principles study of the structural preference and magnetic properties of mononitrides of the d-block metals