#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <climits>
#include <cctype>
#define rg register
#define Fo(i,a,b) for(int i=(a);i< (b);++i)
#define Fr(i,a,b) for(int i=(a);i<=(b);++i)
#define Fl(i,a,b) for(int i=(a);i>=(b);--i)
#define Fill(x,n) memset((x),(n),sizeof(x))
using namespace std;
typedef long long ll;
typedef unsigned int uint;
const int MX=300;
int N;
/*
const uint A[]=
{
	0b11001001,
	0b10101010,
	0b10011100,
	0b11000110,
	0b10100101,
	0b10010011,
	0b11110000
};
*//*
const uint A[]=
{
	0b10011100,
	0b10101010,
	0b11001001,
	0b10010011,
	0b10100101,
	0b11000110,
	0b11110000
};*/

char A[MX][MX];

void solve(int N)
{
	if(N==1){A[0][0]=1;return;}
	solve(N-1);
	int x=1<<(N-1),y=x-1;
	Fo(i,0,y)Fo(j,0,x)
		A[y+i][j]=A[i][j];
	Fo(i,0,y)Fo(j,0,x)
		A[i][x+j]=A[y-1-i][j];
	Fo(i,0,y)Fo(j,0,x)
		A[y+i][x+j]=A[i][x+j]^1;
	Fo(j,0,x)A[y+y][j]=1;
//	Fo(i,0,(1<<N)-1){Fo(j,0,1<<N)printf("%d",A[i][j]);printf("\n");}
}

/*
int check(int N)
{
	int x=1<<N;
	int y=x-1;
	int z=-1;
	Fo(i,0,x)Fo(j,0,x)if(i!=j)
	{
		int cnt=0;
		Fo(k,0,y)if(A[k][i]==A[k][j])++cnt;
		printf("%d\n",cnt);
		if(z==-1)z=cnt;
		else if(z!=cnt)return 0;
	}
	return 1;
}
*/
/*
int main()
{
	solve(5);
	int res=check(5);
	printf("%d\n",res);
	return 0;
}
*/
int main()
{
	scanf("%d",&N);
	solve(N);
	int x=1<<N,y=x-1;
	printf("%d\n",y);
	Fo(i,0,y)Fo(j,0,x)A[i][j]+='A';
	Fo(i,0,y)printf("%s\n",A[i]);
}
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0, length = n; i < length; i++)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ep emplace
#define epb emplace_back
#define scll static_cast<long long> 
#define sz(x) static_cast<int>((x).size())
#define pfll(x) printf("%lld\n", x)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define ci3(x, y, z) cin >> x >> y >> z
#define ci4(w, x, y, z) cin >> w >> x >> y >> z
#define co(x) cout << x << endl
#define co2(x, y) cout << x << " " << y << endl
#define co3(x, y, z) cout << x << " " << y << " " << z << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int>> PQG;
typedef priority_queue<P> PQP;
typedef priority_queue<P, vector<P>, greater<P>> PQPG;

const int MAX_N = 2e5, MOD = 1e9 + 7, INF = 1e9;
int n, po[8];
vector<string> s[8];

int main() {
    ci(n);
    po[0] = 1;
    rep(i, n - 1) po[i + 1] = 2 * po[i] + 1;
    s[0].epb("AB");
    rep(i, n - 1) {
        rep(j, po[i]) {
            string tmp1, tmp2;
            for (auto &c: s[i][j]) {
                tmp1.append(2, c);
                tmp2.append(1, c);
                tmp2.append(1, 'A' + (c - 'A' + 1) % 2);
            }
            s[i + 1].epb(tmp1);
            s[i + 1].epb(tmp2);
        }
        string tmp;
        rep(j, po[i] + 1) tmp.append("AB");
        s[i + 1].epb(tmp);
    }
    co(po[n - 1]);
    rep(i, po[n - 1]) co(s[n - 1][i]);
    return 0;
}
