import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.HashMap;
import java.util.Scanner;

public class Question5 {
	static HashMap<Integer, String> hashes;

	static char[] chars = new char[] {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

	public static void main(String[] args) throws Exception {
		hashes = new HashMap<Integer, String>();
		for (int i = 0; i < chars.length; i++) {
			for (int j = 0; j < chars.length; j++) {
				for (int k = 0; k < chars.length; k++) {
					for (int l = 0; l < chars.length; l++) {
						hashes.put(getHash(new char[] {chars[i], chars[j], chars[k], chars[l]}), chars[i] + "" + chars[j] + "" + chars[k] + "" + chars[l]);
					}
				}
			}
		}
		System.out.println("done");
		BufferedWriter fileout = new BufferedWriter(new FileWriter("OUT5.txt"));
		Scanner scan = new Scanner(new FileReader("DATA5.txt"));
		while (scan.hasNextLine()) {
			String line = scan.nextLine();
			fileout.append(hashes.get(Integer.valueOf(line)));
			fileout.newLine();
		}
		fileout.close();
	}

	public static int getHash(char[] input) {
		int k = input[0] * 1000000 + input[1] * 10000 + input[2] * 100 + input[3];
		int m = input[0] * 11 + input[1] * 101 + input[2] * 1009 + input[3] * 10007;
		return k % m;
	}
}
