#include<bits/stdc++.h>
#define PB emplace_back
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
template<typename T>
void read(T &x){
	int ch = getchar(); x = 0; bool f = false;
	for(;ch < '0' || ch > '9';ch = getchar());
	for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
	if(f) x = -x;
}
template<typename T>
bool chmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
template<typename T>
bool chmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
int n, lim;
int main(){
	read(n); lim = 1<<n; printf("%d\n", lim-1);
	for(int k = 1;k < lim;++ k){
		for(int i = 0;i < lim;++ i)
			putchar((__builtin_popcount(i&k) & 1) + 'A');
		putchar('\n');
	}
}
#include <iostream>
#include <vector>

using namespace std;
vector<vector<int>> solve(int n){
    if(n==1){
        vector<vector<int>> v;
        v.resize(1);
        v[0].push_back(0); v[0].push_back(1);
        return v;
    }
    vector<vector<int>> u = solve(n - 1);
    vector<vector<int>> v;
    int x = (1<<n) - 1;
    v.resize(x);
    int s = 0;
    for(int i=0;i<u.size();i++){
        for(int k=0;k<2;k++){
            for(int j=0;j<u[i].size();j++){
                v[s].push_back(u[i][j]);
            }
            for(int j=0;j<u[i].size();j++){
                v[s].push_back(u[i][j]^k);
            }
            s++;
        }
    }
    for(int i=0;i<(1<<n);i++){
        if(i<(1<<(n - 1))) v[s].push_back(0);
        else v[s].push_back(1);
    }
    return v;
}

int main(){
    int i,n; cin >> n;
    vector<vector<int>> v = solve(n);
    cout << (1<<n) - 1 << endl;
    for(i=0;i<(1<<n) - 1;i++){
        for(int j: v[i]){
            if(j==0) cout << "A";
            else cout << "B";
        }
        cout << endl;
    }
}