#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define sz(x) int(x.size())
// #define show(x) {for(auto i:x){cout << i << " ";} cout << endl;}
#define isin(x,l,r) ((l)<=(x) && (x)<(r))
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<typename T>bool chmin(T&x,const T&y) {if(x>y){x=y;return true;} else return false;}
template<typename T>bool chmax(T&x,const T&y) {if(x<y){x=y;return true;} else return false;}

void show(vector<int> A) {
    for (int a : A) {
        if (a==0) cout << 'A';
        else cout << 'B';
    }
    cout << '\n';
}

int main() {
    int N;
    cin >> N;
    int M = 1 << N;
    cout << M-1 << '\n';
    for (int i = 1; i < M; i++) {
        vector<int> A(M);
        for (int j = 0; j < M; j++) {
            int p = __builtin_popcountll(i&j);
            if (p&1) A[j] = 1;
        }
        show(A);
    }
    return 0;
}
///In the name of GOD
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 5000 + 10;
ll k, n;
ll ans;
vector<string> ANS;
string t, one;
void Print(){
    cout << ans << '\n';
    for(auto X : ANS){
        cout << X << '\n';
    }
    exit(0);
}
string Rev(const string& s){
    t = s;
    reverse(t.begin(), t.end());
    return t;
}
string Not(const string& s){
    t = "";
    for(int i = 0; i < int(s.size()); i ++){
        if(s[i] == 'A') t += "B";
        else            t += "A";
    }
    return t;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> k, n = (1LL << k);
    ans = 1;
    ANS.push_back("AB");
    one = "A";
    for(int i = 1; i < k; i ++){
        for(int j = 0; j < ans; j ++){
            ANS.push_back(ANS[j] + Not(ANS[j]));
            ANS[j] = ANS[j] + ANS[j];
        }
        one = one + one;
        ANS.push_back(one + Not(one));
        ans = int(ANS.size());
    }
    Print();
    return 0;
}
/*!
    HE'S AN INSTIGATOR,
    ENEMY ELIMINATOR,
    AND WHEN HE KNOCKS YOU BETTER
    YOU BETTER LET HIM IN.
*/
//! N.N
