#include<iostream>
#include<vector>
#include<string>
using namespace std;

vector<string> f(int n){
    if(n == 1)  return vector<string>{"AB"};
    vector<string> ans = f(n - 1);
    int sz = ans.size();
	for(int t = 0; t < sz; ++t){
        ans[t] = ans[t] + ans[t];
        string s = ans[t];
        int siz = s.size();
        for(int i = siz / 2; i < siz; ++i)  s[i] = "AB"[s[i] == 'A'];
        ans.emplace_back(s);
    }
    string s(1 << (n - 1), 'A'),  ss(1 << (n - 1), 'B');
    ans.emplace_back(s + ss);
    return ans;  
}

int n;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
    cin >> n;
    vector<string> s = f(n);
    cout << s.size() << "\n";
    for(auto &v : s)  cout << v << "\n";
    return 0;
}
#include <bits/stdc++.h>
//#include <chrono>
#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
//using vec = vector<ll>;
//using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

using vec = vector<bool>;
using mat = vector<vec>;
mat solve(int n){
    mat res((1<<n) - 1, vec(1<<n, false));
    rep(i, (1<<(n - 1))) res[0][i] = true;
    if(n == 1){
        return res;
    }else{
        auto lastres = solve(n - 1);
        reps(i, 1, (1<<n) - 1){
            vec &now = res[i], &last = lastres[(i-1)/2];
            rep(j, (1<<(n-1))) now[j] = last[j];
            if(i&1){
                reps(j, (1<<(n-1)), 1<<n) now[j] = last[j - (1<<(n-1))];
            }else{
                reps(j, (1<<(n-1)), 1<<n) now[j] = !last[j - (1<<(n-1))];
            }
        }
        return res;
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>N;
    K = (1<<N) - 1;
    cout<<K<<endl;
    auto res = solve(N);
    rep(i, K){
        rep(j, 1<<N) cout<<(res[i][j] ? 'A' : 'B');
        cout<<endl;
    }
}
