#include <bits/stdc++.h>
#define SZ(v) ((int)(v).size())
using namespace std;

using ll = long long;

template<typename... Args>
void read(Args&... args)
{
	((cin >> args), ...);
}

template<typename... Args>
void write(Args... args)
{
	((cout << args << " "), ...);
}

template<typename... Args>
void writeln(Args... args)
{
	((cout << args << " "), ...); cout << '\n';
}

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	vector<vector<int>> masks;
	int N;
	read(N);
	int nbJoueurs = 1 << N;
	int rep = nbJoueurs-1;
	writeln(rep);
	for (int i(0); i < rep; ++i)
	{
		for (int j(0); j < nbJoueurs; ++j)
			cout << (__builtin_popcount( i | j) % 2 ? 'B' : 'A');
		writeln();
	}
}

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

string revAB(string str) {
    for(int i=0;i<str.size();++i) str[i]=(str[i]=='A'?'B':'A');
    return str;
}

int main() {
    int N,M; cin >> N; M = (1<<N);
    vector<vector<string>> S(N+1);
    S[1] = {"AB"};
    for(int i=2;i<=N;++i) {
        int L = (1<<i);
        S[i].push_back(string(L/2,'A')+string(L/2,'B'));
        for(int j=0;j<S[i-1].size(); ++j) {
            S[i].push_back(S[i-1][j]+S[i-1][j]);
        }
        for(int j=0;j<S[i-1].size(); ++j) {
            S[i].push_back(S[i-1][j]+revAB(S[i-1][j]));
        }
    }
    cout << S[N].size() << "\n";
    for(auto& s:S[N]) {
        cout << s << "\n";
    }
    return 0;
}