#include <iostream>
#include <fstream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	ifstream input; 
	input.open("DATA5.txt");
	ofstream output;
	output.open("OUT5.txt");

	long remainder;
	for (int f = 0; f < 5; f++)
	{
		input >> remainder;
		
		long k = 0;
		long m = 0;
		long hash = 0;

		for (long i = 65; i <= 90; i++)
		{
			for (long j = 65; j <= 90; j++)
			{
				for (long y = 65; y <= 90; y++)
				{
					for (long l = 65; l <= 90; l++)
					{
						k = long(i*1000000) + long(j*10000) + long(y*100) + long(l);
						m = i*11 + j*101 + y*1009 + l*10007;
						hash = k%m;
						if (hash == remainder)
						{
							output << char(i) << char(j) << char(y) << char(l) << endl;
						}
					}
				}
			}
		}
	}

	input.close();
	output.close();
	return 0;
}
