Ab initio calculation of electronic structure and magnetic properties of R2Fe14BNx (R = Pr,Nd)