// Author: wlzhouzhuan
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fir first
#define sec second
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, t) memset(s, t, sizeof(s))
#define mcpy(s, t) memcpy(s, t, sizeof(t))
template<typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> void ckmax(T1 &a, T2 b) { if (a < b) a = b; }
int read() {
  int x = 0, f = 0; char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = 10 * x + ch - '0', ch = getchar();
  return f ? -x : x;
}
template<typename T> void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
template<typename T> void print(T x, char let) {
  print(x), putchar(let);
}

int n;
int main(){
	n=read();
	printf("%d\n",(1<<n)-1);
	for(int i=1;i<(1<<n);++i){
		for(int j=0;j<(1<<n);++j){
			putchar((__builtin_popcount(i&j)&1)+'A');
		}
		putchar('\n');
	}
	return 0;
}

/**
 *  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;
}
