First-Principles Study of Structural and Magnetic Properties of R(Fe,Ti)12 and R(Fe,Ti)12N (R = Nd, Sm, Y)