Theoretical study of the phase stability and site preference for R3(Fe,T)29 (R=Nd, Sm; T=V, Ti, Cr, Cu, Nb, Mo, Ag)