#include<iostream>
#include<math.h>
using namespace std;
int k=0;
bool hw(int n)
{
int x,a,b=0;
x=n;
while(x)
{
a=x%10;
x/=10;
b=b*10+a;
k+=a;
}
if(b==n) return true;
else return false;
}
bool pf(int n)
{
int m=sqrt(n);
if(m*m==(n)) return true;
else return false;
}
int main()
{
int i;
for(i=10000;i<=99999;i++)
{
//hw(i);
//cout<<k<<" ";
if(hw(i) && pf(i) && pf(k) && k/100==0 && k/10!=0 && pf(k/10+k%10))
cout<<i<<" ";
k=0;
}
return 0;
}