#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

vector<string> f(ll N) {
    if(N == 1) {
        return {"AB"};
    }
    auto v = f(N - 1);
    vector<string> ret;
    for(int i = 0; i < v.size(); i++) {
        auto tmp = v[i] + v[i];
        ret.push_back(tmp);
    }
    for(int i = 0; i < v.size(); i++) {
        auto tmp = v[i];
        for(auto &c: tmp) {
            if(c == 'A') c = 'B';
            else c = 'A';
        }
        tmp += v[i];
        ret.push_back(tmp);
    }
    string S;
    for(int i = 0; i < (1 << N) / 2; i++) S.push_back('A');
    for(int i = 0; i < (1 << N) / 2; i++) S.push_back('B');
    ret.push_back(S);
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    auto ans = f(N);
    cout << ans.size() << endl;
    for(auto s : ans) cout << s << endl;
    return 0;
}
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

int sk(int x) {
	int a=0;
	while (x>0) {
		a+=x%2;
		x=x/2;
		}
	return a;
	}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int k=1;
    for (int i=0;i<n;i++) {k*=2;}
    cout<<k-1<<endl;
    string s="A";
    for (int i=0;i<k-1;i++) {s+='A';}
    vector <string> A(k-1,s);
    for (int i=1;i<k;i++) {
		for (int j=0;j<k;j++) {
			int x=i&j;
			int v=sk(x);
			//cout<<i<<" "<<j<<" "<<x<<" "<<v<<endl;
			if (v%2==0) {A[i-1][j]='B';}
			}
		}
	for (int i=0;i<k-1;i++) {cout<<A[i]<<endl;}
    return 0;
}
