#include <iostream>

using namespace std;

int n;

const int SZ = 1 << 20;

int R1[SZ];
int R2[SZ];

int bits;

int snd(int x)
{
    int ret = 0;
    for(int i = 1 ; i <= bits ; ++i) {
        bool good = bool(x & (1 << i)) == bool(x & (1 << (i - 1)));
        ret |= good << i;
    }
    return ret;
}

int fst(int x)
{
    x ^= 1 << bits;
    return x;
}

bool viz[SZ];
bool choice[SZ];
int x0;

bool DFS(const int x, const int depth) {

    if(depth == n)
        return x == x0;
    if(viz[x])
        return 0;

    viz[x] = 1;

    if(DFS(fst(x), depth + 1)) {
        choice[x] = 0;
        viz[x] = 0;

        return 1;
    }
    if(DFS(snd(x), depth + 1)) {
        choice[x] = 1;
        viz[x] = 0;

        return 1;
    }
    viz[x] = 0;
    return 0;
}

char t[2] = {'A', 'B'};

void bitwise(int num)
{
    for(int i = 0 ; i <= bits ; ++i)
        cout << t[(bool)num & (1 << i)];
}

void operations(int st)
{
    for(int i = 1 ; i <= n ; ++i) {
        cout << choice[st] + 1;
        if(choice[st] == 0)
            st = fst(st);
        else
            st = snd(st);
    }
}

int main()
{
    int sol;
    bool found = 0;
    cin >> n;
    for(bits = 1 ; bits < 20 ; ++bits) {

        for(int i = 0 ; i < (1 << (bits + 1)) ; ++i) {
            x0 = i;

            if(DFS(i, 0)){

                sol = i;
                found = 1;
                break;
            }
        }
        if(found)
            break;
    }
    if(!found)
        cout << "NO\n";
    else {
        bitwise(sol);
        cout << "\n";
        operations(sol);
    }

    return 0;
}
