#include <iostream>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cstring>
using namespace std;
int ant;
map<int, string> poss;
set<int> v;
//ofstream fout("bash.txt");
int encode(string s)
{
    int k = 1000000*((int)s[0]) + 10000*((int)s[1]) + 100*((int)s[2]) + (int)s[3], m = 11*(int)s[0] + 101*(int)s[1] + 1009*(int)s[2] + 10007*(int)s[3];
    return (k%m);
}
void perm(int d, string s)
{
    if (d == 4)
    {
//        map<int, string>::iterator it;
        int temp = encode(s);
//        it=poss.find(temp);
//        if (it==(poss.end()))
//        {
            poss[temp] = s;
//        }
//        else
//        {
//            v.insert(poss.find(encode(s))->first);
//            ant++;
//        }
//        fout << "poss[" << encode(s) << "] = \"" << s << "\";" << endl;
    }
    else
    {
        for (int i = 1; i < 13; i++)
        {
            string t = s + char(i + 64);
            perm(d + 1, t);
        }
    }
}
int main()
{
    freopen("DATA5.txt", "r", stdin);
    freopen("OUT5.txt", "w", stdout);
//    ant = 0;
    perm(0, "");
//    cout << ant + v.size() << endl;
    for (int i = 0; i < 5; i++)
    {
        int n;
        cin >> n;
        cout << poss.find(n) -> second << endl;
    }
    return 0;
}

