#include <bits/stdc++.h>
using namespace std;
int main()
{
    int ge,shi,bai,qian;
    for (int i = 1000;i<=9999;i++)
    {
        ge = i % 10;
        shi = i/10 % 10;
        bai = i / 100 % 10;
        qian  = i/ 1000;
        if (ge ==shi && bai == qian && sqrt(i)==int(sqrt(i)))
        {
            cout << i<<endl; 
        }

    }


    return 0;
}
/**************************************************************
	Problem: 1092
	User: mariooo
	Language: C++
	Result: Accepted
	Time:4 ms
	Memory:2072 kb
****************************************************************/