#include<bits/stdc++.h>
using namespace std;
int main(){
int n=0,x,i,j=0,g=0,o=0,l=0,b[500];
bool r=0;
int a[8];
for(i=1000;i<=3162;i++){
r=1;
g=i*i;
while(g!=0){
a[j]=g%10;
j++;
g/=10;
}
if(j==7){
for(o=6;o>=0;o--){
for(l=o-1;l>=0;l--){
if(a[o]==a[l])
r=0;
}
}
}
if(r==1){
b[n]=i*i;
n++;
}
j=0;
}
for(i=0;i<n;i++){
cout<<b[i];
if((i+1)%10==0)
cout<<endl;
else
cout<<" ";
}
return 0;
}
/**************************************************************
Problem: 2097
User: houshanglin
Language: C++
Result: Accepted
Time:4 ms
Memory:2072 kb
****************************************************************/