// The "DWITER1P5" class.
// Ning Lin
import java.awt.*;
import java.io.*;
import java.util.*;

public class DWITER1P5
{
    public static void main (String[] args) throws IOException
    {
	BufferedReader in = new BufferedReader (new FileReader ("DATA5.txt"));
	PrintWriter out = new PrintWriter (new FileWriter ("OUT5.txt"));
	String alpha = " ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	long input[] = new long [5];
	char letters[] = new char [4];
	String output[] = new String [5];
	long kfx = 0;
	long mfx = 0;
	long suspect = 0;
	for (int z = 0 ; z < 5 ; z++)
	{
	    input [z] = Integer.parseInt (in.readLine ());
	    for (int i = 65 ; i < 91 ; i++)
	    {
		for (int j = 65 ; j < 91 ; j++)
		{
		    for (int k = 65 ; k < 91 ; k++)
		    {
			for (int l = 65 ; l < 91 ; l++)
			{
			    kfx = i * 1000000 + j * 10000 + k * 100 + l;
			    mfx = i * 11 + j * 101 + k * 1009 + l * 10007;
			    suspect = kfx % mfx;
			    if (suspect == input [z])
			    {
				//System.out.println ("catch");
				output [z] = alpha.charAt (i - 64) + "" + alpha.charAt (j - 64) + "" + alpha.charAt (k - 64) + "" + alpha.charAt (l - 64) + "";
			    }
			}
		    }
		}
	    }
	    out.println (output [z]);
	}
	out.close ();
	// Place your program here.  'c' is the output console
    } // main method
} // DWITER1P5 class



