#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
//#define DIV 1000000007
//#define DIV 998244353

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
	ll N;
	cin >> N;

	vector<string> ans;
	ans.push_back("AB");

	rep(i, N-1) {
		vector<string> n_ans;
		for(string s: ans) {
			n_ans.push_back(s + s);
		}

		for(string s: ans) {
			string rev = "";
			for(char ch: s) {
				if(ch == 'A') {
					rev += "B";
				} else {
					rev += "A";
				}
			}
			n_ans.push_back(s + rev);
		}

		string s = "";
		rep(i, n_ans[0].size()/2) s += "A";
		rep(i, n_ans[0].size()/2) s += "B";
		n_ans.push_back(s);

		swap(ans, n_ans);
	}
	cout << ans.size() << endl;
	for(auto s: ans) cout << s << endl;
}

#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<bool> b(2);
    b[0] = true, b[1] = false;
    set<vector<bool>> st0;
    st0.insert(b);
    for(int c = 2; c <= n; c++){
        set<vector<bool>> st1;
        int l = (1 << (c - 1));
        for(auto itr = st0.begin(); itr != st0.end(); itr++){
            vector<bool> b = *itr;
            b.resize(l * 2);
            for(int i = l - 1; i >= 0; i--){
                b[i * 2 + 1] = b[i * 2] = b[i];
            }
            st1.insert(b);
            if(b[1] == b[2]) continue;
            for(int i = 0; i < l / 2; i++){
                swap(b[i * 4 + 1], b[i * 4 + 2]);
            }
            st1.insert(b);
            for(int i = 0; i < l / 2; i++){
                swap(b[i * 4 + 2], b[i * 4 + 3]);
            }
            st1.insert(b);
        }
        swap(st0, st1);
    }
    cout << (int)st0.size() << endl;
    for(auto itr = st0.begin(); itr != st0.end(); itr++){
        for(bool e : *itr){
            if(e) cout << 'A';
            else cout << 'B';
        }
        cout << endl;
    }
}
