#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PI = pair<pair<int,int>,int>;
using PL = pair<long long, long long>;
using PLL = pair<pair<long long, long long>, long long>;
using Pxy = pair<long double, long double>;
const int INF = 2001001007;
const int modd = 1000000007;
const long long modl = 1000000007LL;
const long long mod = 998244353LL;
const ll inf = 1e18;
template <typename SA>
void priv(vector<SA> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename SB>
void privv(vector<vector<SB>> &ar){
    rep(i,ar.size()){
        rep(j,ar[i].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[i].size()-1] << endl;
    }
}
template <typename SC>
bool range(SC a, SC b, SC x){return (a <= x && x < b);}
bool rrange(P a, P b, P xy){
    bool s = range(a.first,b.first,xy.first);
    bool t = range(a.second,b.second,xy.second);
    return (s && t);
}
template <typename SD>
void sor(vector<SD> &ar){sort(ar.begin(),ar.end());}
template <typename SE>
void rev(vector<SE> &ar){reverse(ar.begin(),ar.end());}
template <typename SF>
bool chmin(SF &a, const SF &b){if(a>b){a = b; return true;} return false;}
template <typename SG>
bool chmax(SG &a, const SG &b){if(a<b){a = b; return true;} return false;}
template <typename SH>
void eru(vector<SH> &ar){sor(ar);ar.erase(unique(ar.begin(),ar.end()),ar.end());}

void yes(){cout << "Yes" << endl;}
void no (){cout << "No" << endl;}
void yn (bool t){if(t)yes();else no();}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

vector<string> saiki(int n){
    if (n == 1){
        vector<string> ans = {"AB"};
        return ans;
    }
    vector<string> a = saiki(n/2);
    vector<string> ans(2*n-1);
    string c = "";
    rep(i,n) c += 'A';
    rep(i,n) c += 'B';
    ans[0] = c;
    rep(i,n-1){
        string d = a[i];
        d += a[i];
        ans[i+1] = d;
    }
    rep(i,n-1){
        string d = a[i];
        rep(j,n){
            if (d[j] == 'A') d += 'B';
            else d += 'A';
        }
        ans[n+i] = d;
    }
    return ans;
}

int main(){
    int n; cin >> n;
    int m = 1;
    rep(i,n-1) m *= 2;
    auto ans = saiki(m);
    cout << ans.size() << endl;
    rep(i,ans.size()) cout << ans[i] << endl;
}
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
    fastIO;
    int n;
    cin >> n;
    vector<vector<int>> sol;
    sol.push_back({0,1});
    for(int i = 2; i <= n; i ++ ){
        vector<vector<int>> nw;
        for(auto x : sol){
            nw.push_back({});
            for(auto r : x){
                nw.back().push_back(r);
            }
            for(auto r : x){
                nw.back().push_back(r);
            }
            nw.push_back({});
            for(auto r : x){
                nw.back().push_back(r);
            }
            for(auto r : x){
                nw.back().push_back((r^1));
            }
        }
        nw.push_back({});
        for(int j = 0 ; j < (1 << i); j ++ ){
            if(j < (1 << (i - 1))){
                nw.back().push_back(0);
            }
            else{
                nw.back().push_back(1);
            }
        }
        sol = nw;
    }
    cout << sol.size() << "\n";
    for(auto p : sol){
        for(auto q : p){
            cout << char(q+'A');
        }
        cout << "\n";
    }
    return 0;
}
