#include <bits/stdc++.h>

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

vector<string> ans;
ll S[300][300];

void push(string &s, ll len) {
    ans.push_back(s);
    REP(i, len) {
        REP(j, i) {
            if (s[i] == s[j]) {
                S[i][j]++;
                S[j][i]++;
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll p = pow(2LL, N);

    memset(S, 0, sizeof(S));
    REP(i, p) {
        S[i][i] = INF;
    }
    while (true) {
        vector<ll> v;
        while (v.size() < p / 2) {
            pll x(-1, INF);
            REP(i, p) {
                ll sum = 0;
                REP(j, v.size()) {
                    sum += S[i][v[j]];
                }
                if (x.second > sum)
                    x = pll(i, sum);
            }
            v.push_back(x.first);
        }
        string s = "";
        REP(i, p) {
            s.push_back('A');
        }
        REP(i, v.size()) {
            s[v[i]] = 'B';
        }
        push(s, p);
        bool e = true;
        REP(i, p) {
            FOR(j, p, i + 1) {
                if (S[i][j] != S[0][1]) {
                    e = false;
                }
            }
            if (!e)
                break;
        }
        if (e)
            break;
    }

    cout << ans.size() << endl;
    REP(i, ans.size()) {
        cout << ans[i] << endl;
    }
    return 0;
}
#include<iostream>
#include<array>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

int N;

vector<vector<int>> calc(int n){
  if(n==1){
    return {{0,1}};
  }
  int h=(1<<n)-1,w=(1<<n);
  vector<vector<int>> S=calc(n-1),res((1<<n)-1,vector<int>(1<<n));
  rep(i,(h-1)/2){
    rep(j,w/2){
      res[i][j]=S[i][j];res[i][j+w/2]=S[i][j];
      res[i+(h-1)/2][j]=S[i][j];res[i+(h-1)/2][j+w/2]=1-S[i][j];
    }
  }
  rep(i,(1<<(n-1))) {
    res[h-1][i]=0;
    res[h-1][i+w/2]=1;
  }
  return res;
}

void solve(){
  cin >> N;
  vector<vector<int>> ans=calc(N);
  cout << ans.size() << endl;
  rep(i,ans.size()){
    for(int t:ans[i]){
      if(t==0) cout << "A";
      else cout << "B";
    }
    cout << "" << endl;
  }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}