/**
 *  created: 16/01/2021, 14:27:24
**/

#include <bits/stdc++.h>

using namespace std;

const int max_n = 1111, inf = 1000111222;

int n, cnt[max_n][max_n];
vector<string> ans;

int c2(int n) {
    return n * (n - 1) / 2;
}

bool get_bit(int mask, int pos) {
    return (mask >> pos) & 1;
}

void check() {
    for (string s : ans) {
        if (!(s.length() == (1 << n))) {
            cout << s.length() << endl;
            cout << (1 << n) << endl;
            exit(2);
        }
        for (int i = 0; i < s.length(); ++i) {
            for (int j = i + 1; j < s.length(); ++j) {
                cnt[i][j] += s[i] == s[j];
            }
        }
    }
    for (int i = 0; i < (1 << n); ++i) {
        for (int j = i + 1; j < (1 << n); ++j) {
            cout << cnt[i][j] << " ";
        }
        cout << endl;
    }
}

vector<string> solve(int n) {
    if (n == 1) {
        return {"AB"};
    }
    vector<string> v = solve(n - 1);
    vector<string> res;
    for (string s : v) {
        string t = s;
        for (int i = 0; i < t.size(); ++i) {
            t[i] ^= 'A' ^ 'B';
        }
        res.push_back(s + s);
        res.push_back(s + t);
    }
    string s;
    for (int i = 0; i < (1 << (n - 1)); ++i) {
        s += 'A';
    }
    for (int i = 0; i < (1 << (n - 1)); ++i) {
        s += 'B';
    }
    res.push_back(s);
    return res;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    /*int a = c2(1 << (n - 1)) * 2;
    int b = c2(1 << n);
    int lc = a / __gcd(a, b) * b;
    cout << a << " " << b << " " << lc << endl << lc / a << endl;*/
    /*
    ans.push_back("AABB");
    ans.push_back("ABAB");
    ans.push_back("ABBA");
    */

    ans = solve(n);

    /*ans.push_back("AAAABBBB");

    ans.push_back("AABBAABB");
    ans.push_back("ABABABAB");
    ans.push_back("ABBAABBA");

    ans.push_back("AABBBBAA");
    ans.push_back("ABABBABA");
    ans.push_back("ABBABAAB");*/

    cout << ans.size() << "\n";
    for (auto s : ans) {
        cout << s << "\n";
    }

    //check();

    return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
int N,M,a[1100][1100];
signed main(){
  cin>>N;M=(1<<N);
  cout<<M-1<<endl;
  for(int i=1;i<M;i++){
    string ans(M,'A');
    for(int k=0;k<M;k++)if(__builtin_popcount(i&k)&1)ans[k]='B';
    cout<<ans<<endl;
  }
}