#include <bits/stdc++.h>
using namespace std;
int main()
{

    for (long long i = 100000; i < 1000000; i++)
    {
        //i要用longlong，不然相乘会溢出
        set<int> s1, s2;
        int t1 = i;
        while (t1)
        {
            s1.insert(t1 % 10);
            t1 /= 10;
        }
        long long t2 = i * i;
        if (s1.size() == 6)
        {
            while (t2)
            {
                s2.insert(t2 % 10);
                t2 /= 10;
            }
            bool flag = 1;
            for (auto it : s1)
            {
                if (s2.find(it) != s2.end())
                {
                    flag = 0;
                    break;
                }
            }
            if (flag == 1)
                cout << i << ' ' << i * i << endl;
        }
        s1.clear();
        s2.clear();
    }

    return 0;
}
