main=mapM print[n|n<-[1..2000],f n!!9<2] f n=n:f(sum[read[x]^2|x<-show n])