#include <bits/stdc++.h>
using namespace std;

string rev(string a){//aのAとBを反転させたやつを返す
  for(auto &p:a)p^='A'^'B';
  return a;
}

int main(){
  int n;cin>>n;
  vector<vector<string>> s(n+1);//s[i]:n=iの時の答え
  for(int i=0;i<n;i++){
    for(string p:s[i]){
      s[i+1].push_back(p+p);
      s[i+1].push_back(p+rev(p));
    }
    s[i+1].push_back(string(1<<i,'A')+string(1<<i,'B'));
  }
  cout<<s[n].size()<<endl;
  for(string p:s[n])cout<<p<<endl;
}

//#include <atcoder/math>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define INF_LL 100000000000000000LL
#define INF 2000000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};
typedef vector<vector<edge>> graph;

// using mint = modint998244353;

char inv(char c){
    if(c == 'A') return 'B';
    return 'A';
}

vector<string> solve(int n){
    if(n == 1){
        return {"AB"};
    }
    vector<string> t = solve(n - 1);
    vector<string> res(t.size() * 2 + 1);
    rep(i, t.size()){
        rep(j, t[i].size()){
            res[i * 2] += t[i][j];
            res[i * 2] += t[i][j];
            res[i * 2 + 1] += t[i][j];
            res[i * 2 + 1] += inv(t[i][j]);
        }
    }
    rep(i, t.size() * 2 + 2){
        int cnt = 0;
        rep(j, res.size() - 1){
            if(res[j][i] == 'A') cnt++;
        }
        if(cnt != t.size()){
            res[res.size()-1]+='A';
        }else{
            res[res.size()-1]+='B';
        }
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    vector<string> ans = solve(n);
    int k = ans.size();
    vector<vector<int>> c(ans[0].size(), vector<int>(ans[0].size()));
    cout << k << endl;
    rep(i, k){
        string res = ans[i];
        cout << res << endl;
        rep(i, res.size()) REP(j, i + 1, res.size()) {if(res[i] == res[j])c[i][j]++;}
    }
    // int t = c[0][1];
    // rep(i, n) REP(j, i + 1, n) {
    //     if(c[i][j] != t){
    //         cout << i << " " << j << " " << c[i][j] << endl;
    //     }
    // }
    return 0;
}
