First-principles study of mechanical and magnetic properties of transition metal (M) nitrides in the cubic M4N structure