Conditions of formation of lanthanum and samarium nitrides