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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define STRING(str) #str
#define ll long long
#define ld long double

template <typename T>
void print(T x, string name) {
	cout << name+": " << x << endl;
}

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

template <typename T >
void print_vec_2d(vector<vector<T>> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << "[ ";
		for (int j=0;j<x[i].size();j++) {
			cout << x[i][j];
			if (j != x[i].size()-1) cout << ", ";
			else {
				cout << " ]";
				if (!((i == x.size()-1) && (j == x[i].size()-1))) {
					cout << "," << endl;
				}
			}
		}
	}
	cout << " ]" << endl;
}

template <typename T >
void print_vec_3d(vector<vector<vector<T>>> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << "[ ";
		for (int j=0;j<x[i].size();j++) {
			cout << "[ ";
			for (int k=0;k<x[i][j].size();k++) {
				cout << x[i][j][k];
				if (k != x[i][j].size()-1) cout << ", ";
				else {
					cout << " ]";
					if (!((i == x.size()-1) && (j == x[i].size()-1) && (k == x[i][j].size()-1))) {
						cout << "," << endl;
					}
				}
			}
			if (j != x[i].size()-1) cout << ", ";
			else {
				cout << " ]";
				if (!((i == x.size()-1) && (j == x[i].size()-1))) {
					cout << "," << endl;
				}
			}
		}
	}
	cout << " ]" << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int N;
	cin >> N;

	int n = (1<<N)-1;
	vector<string> ans_str;
	for (int i=0;i<n;i++) {
		string tmp = "";
		for (int j=0;j<(1<<N);j++) tmp += "B";
		ans_str.push_back(tmp);
	}

	for (int i=1;i<(1<<N);i++) {
		for (int j=0;j<(1<<N);j++) {
			if (__builtin_popcount(j&i)%2 == 1) ans_str[i-1][j] = 'A';
 		}
	}

	cout << n << "\n";
	for (int i=0;i<n;i++) {
		cout << ans_str[i] << "\n";
	}
}
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

vector<string> rec(int n){
  if(n==2) return vector<string> (1,"AB");
  vector<string> base=rec(n/2);
  vector<string> revbase=base;
  rep(i,revbase.size()) rep(j,revbase[i].size()){
    if(revbase[i][j]=='A') revbase[i][j]='B';
    else revbase[i][j]='A';
  }

  vector<string> result;
  rep(i,base.size()) result.push_back(base[i]+base[i]);
  rep(i,base.size()) result.push_back(base[i]+revbase[i]);
  result.push_back(string(n/2,'A')+string(n/2,'B'));
  return result;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin>>N;
  int M=(1<<N);

  vector<string> output=rec(M);
  cout<<output.size()<<"\n";
  rep(i,output.size()) cout<<output[i]<<"\n";

  return 0;
}
