#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T1, class T2> inline bool chmax(T1 &a, const T2 &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T1, class T2> inline bool chmin(T1 &a, const T2 &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T> void verr(const set<T> &st) { repa(a, st) cerr << a << " "; cerr << endl; }
template <class S, class T> void verr(const map<S, T> &mp) { repa(a, mp) cerr << "{" << a.first << ", " << a.second << "} "; cerr << endl; }
template <class S, class T, class N> void verr(const vector<pair<S,T>>& a, const N& n) { rep(i, n) cerr << "{" << a[i].first << ", " << a[i].second << "} "; cerr << endl; }
template <class T, class N> void verr(const vector<T>& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << endl; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << endl; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    ll N;
    cin >> N;
    ll bn = (1 << N);
    cout << bn - 1 << '\n';
    
    repe(i, 1, bn){
        string ans;
        rep(j, bn) {
            if(__builtin_popcount(i & j) % 2 == 0)
                ans += 'A';
            else
                ans += 'B';
        }
        cout << ans << '\n';
    }
}
#include <bits/stdc++.h>

using namespace std;

bool brute(int n,int k,vector<vector<int>> &a,vector<int> &b){
	if(k==0){
		bool bo=true;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(a[i][j]!=a[0][1]){
					bo=false;
					break;
				}
			}
			if(!bo) break;
		}
		if(bo){
			cout << "conglats" << a[0][1] << "\n";
			for(int i=0;i<(int)b.size();i++) cout << b[i] << " ";
			cout << "\n";
			return true;
		}
		return false;
	}
	for(int i=0;i<(1<<n);i++){
		if(__builtin_popcount(i)!=(n/2)) continue;
		for(int s=0;s<n;s++){
			for(int t=s+1;t<n;t++){
				if(((i>>s)&1)==((i>>t)&1)){
					a[s][t]++;
				}
			}
		}
		b.push_back(i);
		if(brute(n,k-1,a,b)) return true;
		b.pop_back();
		
		for(int s=0;s<n;s++){
			for(int t=s+1;t<n;t++){
				if(((i>>s)&1)==((i>>t)&1)){
					a[s][t]--;
				}
			}
		}
	}
	return false;
}
void kasan(string str,vector<vector<int>> &a){
	for(int i=0;i<(int)str.size();i++){
		for(int j=i+1;j<(int)str.size();j++){
			if(str[i]==str[j]) a[i][j]++;
		}
	}
}
string xors(string &a,string &b){
	int n=(int)a.size();
	string res;
	for(int i=0;i<n;i++){
		if(a[i]==b[i]) res.push_back('A');
		else res.push_back('B');
	}
	return res;
}
int main(){
	//ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	int m=1<<n;
	int kumi=m*(m-1)/2;
	int sou=(m/2-1)*(m/2);
	
	int g=__gcd(sou,kumi);
	
	cout << kumi/g << "\n";
	
	int cnt=0;
	vector<vector<int>> a(m,vector<int>(m));
	vector<string> st;
	for(int h=1;h<m;h*=2){
		//000...111...
		string str;
		for(int j=0;j<m;j++){
			if((j/h)&1) str.push_back('B');
			else str.push_back('A');
		}
		kasan(str,a);
		int sz=(int)st.size();
		cout << str << "\n";
		for(int j=0;j<sz;j++){
			string str2=xors(st[j],str);
			cout << str2 << "\n";
			kasan(str2,a);
			st.push_back(str2);
		}
		st.push_back(str);
	}
	return 0;
}