#include<cstdio>

int n;
int cnt[500];

int main(){
    for(int i = 1; i <= 255; ++i)  cnt[i] = cnt[i >> 1] + (i & 1);
    scanf("%d", &n);
    printf("%d\n", (1 << n) - 1);
	for(int i = 1; i < (1 << n); ++i){
        for(int t = 1; t <= (1 << n); ++t)
            printf("%c", (cnt[t & i] & 1) ? 'A' : 'B');
    	puts(""); 
	}    
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;

ll rd(){
	int f = 1;
	ll x = 0;
	char ch = getchar();
	while(ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();		
	}
	while(ch >= '0' && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

ll ksm(ll a,ll b,ll m){
	ll base = a;
	ll ans = 1;
	while(b){
		if(b & 1) {
			ans *= base;
			ans %= m;
		}
		base *= base;
		base %= m;
		b >>= 1;
	}
	return ans;
}

int main(){
	int n = rd();
	vector<string> ans;
	ans.push_back("AB");
	for(int i = 2;i <= n;i++) {
		for(int j = 0;j < (1 << (i - 1)) - 1;j++)
			ans[j] += ans[j];
		for(int j = 0;j < (1 << (i - 1)) - 1;j++){
			string s = ans[j];
			for(int k = (1 << (i - 1));k < (1 << i);k++) 
				s[k] ^= 'A' ^ 'B';
			ans.push_back(s);
		}
		ans.push_back(string(1 << (i - 1),'A') + string(1 << (i - 1),'B'));
	}
	cout << ans.size() << '\n';
	for(auto s:ans) cout << s << '\n';
} 
