#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;

int main() {

	ifstream fin("DATA5.txt");
	ofstream fout("OUT5.txt");
	int hash;

	vector<int> nums;
	string pass[5];

	for (int i = 0; i < 5; i++) {
		fin >> hash;
		nums.push_back(hash);
	}

	string empty = "";
	for (char n1 = 'A'; n1 <= 'Z'; n1++) {
		for (char n2 = 'A'; n2 <= 'Z'; n2++) {
			for (char n3 = 'A'; n3 <= 'Z'; n3++) {
				for (char n4 = 'A'; n4 <= 'Z'; n4++) {
					for (int i = 0; i < 5; i++) {
						if ((n1 * 1000000 + n2 * 10000 + n3 * 100 + n4) %
							(n1 * 11 + n2 * 101 + n3 * 1009 + n4 * 10007) == nums[i]) {
								pass[i] = empty + n1 + n2 + n3 + n4;
						}
					}
				}
			}
		}
	}

	for (int i = 0; i < 5; i++) fout << pass[i] << "\n";
}

