#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, x[1001];
int final = 0;
string s = "ABCDEFGH";
char a[1001];
void init(){
for(int i = 0; i <= n - 1; i++){
x[i] = i;
a[i] = s[x[i]];
}
}
bool check(){
for(int i = 1; i < n - 1; i++){
if(a[i] == 'A' || a[i] == 'E'){
if(a[i - 1] != s[0] && a[i- 1] != s[4] && a[i + 1] != s[0] && a[i + 1] != s[4]){
return false;
}
}
}
return true;
}
void gen(){
int i = n - 2;
while(i >= 0 && x[i] >= x[i + 1]){
i--;
}
if(i < 0){
final = 1;
}
else{
for(int j = n - 1; j > i; j--){
if(x[j] >= x[i]){
swap(x[i], x[j]);
break;
}
}
sort(x + i + 1, x + n);
}
for(int i = 0; i < n; i++){
a[i] = s[x[i]];
}
}
int main(){
char c; cin >> c;
n = c - 'A' + 1;
init();
while(!final){
if(check()){
for(int i = 0; i < n; i++){
cout << a[i];
}
cout << endl;
}
gen();
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG4sIHhbMTAwMV07CmludCBmaW5hbCA9IDA7CnN0cmluZyBzID0gIkFCQ0RFRkdIIjsKY2hhciBhWzEwMDFdOwoKdm9pZCBpbml0KCl7CiAgIGZvcihpbnQgaSA9IDA7IGkgPD0gbiAtIDE7IGkrKyl7CiAgICAgIHhbaV0gPSBpOwogICAgICBhW2ldID0gc1t4W2ldXTsKICAgfQp9Cgpib29sIGNoZWNrKCl7CiAgIGZvcihpbnQgaSA9IDE7IGkgPCBuIC0gMTsgaSsrKXsKICAgICAgaWYoYVtpXSA9PSAnQScgfHwgYVtpXSA9PSAnRScpewogICAgICAgICBpZihhW2kgLSAxXSAhPSBzWzBdICYmIGFbaS0gMV0gIT0gc1s0XSAmJiBhW2kgKyAxXSAhPSBzWzBdICYmIGFbaSArIDFdICE9IHNbNF0pewogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgIH0KICAgICAgfQogICB9CiAgIHJldHVybiB0cnVlOwp9Cgp2b2lkIGdlbigpewogICBpbnQgaSA9IG4gLSAyOwogICB3aGlsZShpID49IDAgJiYgeFtpXSA+PSB4W2kgKyAxXSl7CiAgICAgIGktLTsKICAgfQogICBpZihpIDwgMCl7CiAgICAgIGZpbmFsID0gMTsKICAgfQogICBlbHNlewogICAgICBmb3IoaW50IGogPSBuIC0gMTsgaiA+IGk7IGotLSl7CiAgICAgICAgIGlmKHhbal0gPj0geFtpXSl7CiAgICAgICAgICAgIHN3YXAoeFtpXSwgeFtqXSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAgICAgIH0KICAgICAgc29ydCh4ICsgaSArIDEsIHggKyBuKTsKICAgfQogICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsKICAgICAgYVtpXSA9IHNbeFtpXV07CiAgIH0KfQoKCgppbnQgbWFpbigpewogICBjaGFyIGM7IGNpbiA+PiBjOwogICBuID0gYyAtICdBJyArIDE7CiAgIGluaXQoKTsKICAgd2hpbGUoIWZpbmFsKXsKICAgICAgaWYoY2hlY2soKSl7CiAgICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspewogICAgICAgICAgICBjb3V0IDw8IGFbaV07CiAgICAgICAgIH0KICAgICAgICAgY291dCA8PCBlbmRsOwogICAgICB9CiAgICAgIGdlbigpOwogICB9Cn0=