void main(){for(int n,m,l;n<2e3;m=l<5?--l||printf("%d ",n),++n:l)for(l=0;m;m/=10)l+=m%10*(m%10);}