// The "D5" class.
import java.awt.*;
import hsa.Console;
import java.io.*;

public class D5
{
    //static Console c;           // The output console

    public static void main (String[] args) throws IOException
    {
	//c = new Console ();
	BufferedReader br = new BufferedReader (new FileReader ("DATA5.txt"));
	PrintWriter pwr = new PrintWriter (new FileWriter ("OUT5.txt"));
	String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int a, b;
	String out = "";
	for (int count = 0 ; count < 5 ; count++)
	{
	    String str = br.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++)
			{
			    a = i * 1000000 + j * 10000 + k * 100 + l;
			    b = i * 11 + j * 101 + k * 1009 + l * 10007;
			    if (a % b == Integer.parseInt (str))
			    {
				out = alpha.charAt (i - 65) + "" + alpha.charAt (j - 65) + alpha.charAt (k - 65) + alpha.charAt (l - 65) + "";
				pwr.println (out);
			    }
			}
	}
	pwr.close ();
	System.exit(0);
	// Place your program here.  'c' is the output console
    } // main method
} // D5 class

