/*
template   Dwite_IN_out_java.java
*/
import java.io.*;
import java.util.*;

class Dwite {
  public static void main (String [] args) throws IOException {
	String s= "";
	int[] get;
	String[] out;
	int get1, out1;
	get1 = 5;
	out1 = 5;
	get = new int[get1];
	out = new String[out1];
	boolean z = false;

    // Use BufferedReader rather than RandomAccessFile; it's much faster
    BufferedReader f = new BufferedReader(new FileReader("DATA5.txt"));
                                                  // input file name goes above
    PrintWriter out2 = new PrintWriter(new BufferedWriter(new FileWriter("OUT5.txt")));


	for(int i= 0; i <get1; i ++){
		s = f.readLine();
		int fr_num = Integer.parseInt(s);
		get[i] = fr_num;    

			for(int a=65; a<90; a++){
					for(int b=65; b<90; b++){
						for(int c=65; c<90; c++){
							for(int d=65; d<90; d++){
								if((a*1000000+b*10000+c*100 + d)%((a)*11 + (b)*101 + (c)*1009 + (d)*10007)==get[i]){
			
								out[i] = "" +(char)a+""+(char)b+""+(char)c+""+(char)d; break;}
						}
					}
				}
			}



	}
  //  int fr_num = Integer.parseInt(s);
 // out 
	for(int i= 0; i <get1; i ++){
		out2.write(""+  out[i]  + "\n" );  // gets entire line
	}
    


    f.close();
    out2.close();                                  // close the output file
    System.exit(0);                               // don't omit this!

  
   } // end main




}//end class
