#include <iostream>
#include <fstream>

using namespace std;

ifstream reader("DATA5.txt");
ofstream writer("OUT5.txt");

int main(){
    int hash;
    
    for(int asdf = 0; asdf < 5; ++asdf){
        
        reader >> hash;
        
        for(char a = 'A'; a <= 'Z'; ++a){
            for(char b = 'A'; b <= 'Z'; ++b){
                for(char c = 'A'; c <= 'Z'; ++c){
                    for(char d = 'A'; d <= 'Z'; ++d){
                        
                        if((a * 1000000 + b * 10000 + c * 100 + d) % (a * 11 + b * 101 + c * 1009 + d * 10007) == hash)
                            writer << a << b << c << d << '\n';
                        
                    }
                }
            }
        }
        
    }
}

