#include<bits/stdc++.h>
using namespace std;
int f(int x)
{
	int ans=0;
	while(x)
	{
		if(x&1)ans++;
		x>>=1;
	}
	return ans;
} 
int ksm(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans*=a;
		a*=a;
		b>>=1;
	}
	return ans;
}
int main()
{
	int n,m;
	cin>>n;
	m=ksm(2,n)-1;
	cout<<m<<"\n";
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=m+1;j++)
		{
			if(f(i&j)&1)cout<<"A";
			else cout<<"B";
		}
		cout<<"\n";
	}
	return 0;
}
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

char buf[10][2000][2000];
int n;

int main(void) {
  scanf("%d", &n);
  buf[0][0][0] = 'A';
  buf[0][0][1] = 'B';
  REP(k, n-1) {
    REP(i, (1<<(k+1))-1) {
      REP(j, 1<<(k+1)) {
        if(buf[k][i][j] == 'A') {
          buf[k+1][2*i][j*2] = 'A';
          buf[k+1][2*i][j*2+1] = 'A';
        } else {
          buf[k+1][2*i][j*2] = 'B';
          buf[k+1][2*i][j*2+1] = 'B';
        }
      }
      // cerr << "1> " << 2*i << " " << buf[k+1][2*i] << endl;
      REP(j, 1<<(k+1)) {
        if(buf[k][i][j] == 'A') {
          buf[k+1][2*i+1][j*2] = 'A';
          buf[k+1][2*i+1][j*2+1] = 'B';
        } else {
          buf[k+1][2*i+1][j*2] = 'B';
          buf[k+1][2*i+1][j*2+1] = 'A';
        }
      }
      // cerr << "2> " << 2*i+1 << " " << buf[k+1][2*i+1] << endl;
    }
    REP(j, 1<<(k+2)) {
      buf[k+1][((1<<(k+1))-1)*2][j] = j % 2 ? 'B' : 'A';
    }
    // cerr << "3> " << ((1<<(k+1))-1)*2 << " " << buf[k+1][((1<<(k+1))-1)*2] << endl;
  }
  printf("%d\n", (1<<n)-1);
  for(int i = 0; i < (1 << n)-1; ++i) {
    puts(buf[n-1][i]);
  }
  return 0;
}
