#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int main(){
	int n, nn; cin >> n; nn = 1 << n;
	cout << nn-1 << "\n";
	for(int bt=1; bt<nn; bt++){
		rep(i,nn) cout << (char)(__builtin_parity(bt&i) + 'A');
		cout << "\n";
	}
}
#include <bits/stdc++.h>

using namespace std;

// figure out n and m by double counting partnerships
// solved the n = 2 case
// tried natural ways to extend a solution on n to 2n
//  => how to "borrow" structure from the n solution
//  => make a copy of each vertex, how do you link them together
//  => link 1-2 of each team?
//  => link some alternating variant of each team?
//  => i knew i needed to do Two Things, then one more teaming to balance it
//
//  => link 1-2 was natural so that was a good first tep
//  => then i noticed that in all subsequent pairings, i need to not have a 1-2 pair
//  => how do i pair the rest? had the idea of the separate sets of {1, 2} in my head
//  => the next natural thing to do is to take 1 from another team and take 2 from the other team
//  => as a way to still borrow the structure of the n solution
//  => we have to do One operation now, which shouldn't rely on the n solution
//  => a quick check tells us the last team should be all 1s and all 2s
//  which works!

int main() {
    int n; scanf("%d", &n);
    vector<vector<bool>> solution{{true, false}};
    for (int i = 2, sz = 2; i <= n; ++i, sz *= 2) {
        // sz is size of a team
        vector<vector<bool>> ns(2 * solution.size() + 1, vector<bool>(sz * 2));
        for (int g = 0; g < solution.size(); ++g) {
            for (int i = 0; i < sz * 2; ++i) if (solution[g][i % sz]) ns[g][i] = true;
        }
        for (int g = 0; g < solution.size(); ++g) {
            for (int i = 0; i < sz * 2; ++i) 
                if ((i < sz && solution[g][i]) || (i >= sz && !solution[g][i - sz])) ns[g + solution.size()][i] = true;
        }
        for (int i = 0; i < sz; ++i) ns.back()[i] = true;
        solution = ns;
    }
    printf("%lu\n", solution.size());
    for (auto &s : solution) {
        for (bool b : s) printf("%c", b ? 'A' : 'B');
        printf("\n");
    }
    return 0;

    return 0;
}
