#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

string inv(string s) {
    string res;
    for (auto t : s) {
        if (t == 'A') {
            res.push_back('B');
        } else {
            res.push_back('A');
        }
    }
    return res;
}

vector<string> op(vector<string> a) {
    vector<string> res;
    for (auto t : a) {
        res.push_back(t + t);
    }
    for (auto t : a) {
        res.push_back(t + inv(t));
    }
    string s(a[0].size(), 'A');
    res.push_back(s + inv(s));
    // for (auto t : a) {
    //     res.push_back(inv(t) + t);
    // }
    return res;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int k;
    cin >> k;
    if (k == 1) {
        cout << 1 << endl;
        cout << "AB" << endl;
        exit(0);
    }
    vector<string> v = {
        "AABB",
        "ABAB",
        "ABBA"
    };
    for (int i = 2; i < k; i++) {
        v = op(v);
    }
    cout << v.size() << '\n';
    for (auto s : v) {
        cout << s << '\n';
    }
}

#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"

int popcount(long long n) {
	n = (n & 0x5555555555555555) + (n >> 1 & 0x5555555555555555);
	n = (n & 0x3333333333333333) + (n >> 2 & 0x3333333333333333);
	n = (n & 0x0f0f0f0f0f0f0f0f) + (n >> 4 & 0x0f0f0f0f0f0f0f0f);
	n = (n & 0x00ff00ff00ff00ff) + (n >> 8 & 0x00ff00ff00ff00ff);
	n = (n & 0x0000ffff0000ffff) + (n >> 16 & 0x0000ffff0000ffff);
	n = (n & 0x00000000ffffffff) + (n >> 32 & 0x00000000ffffffff);
	return n;
}

char ans[2048][2048];
int main() {
	int N;
	cin >> N;
	int K = (1 << N) - 1;
	cout << K << endl;
	rep(i, (1 << N)) {
		rep(j, (1 << N)) {
			ans[i][j] = 'A';
		}
	}
	rep(i, K) {
		rep(j, (1 << N)) {
			long long pop = popcount((i + 1) & j);
			if (0 == pop % 2) {
				ans[i][j] = 'B';
			}
			else {
				ans[i][j] = 'A';
			}
		}
	}
	rep(i, K) {
		rep(j, (1 << N)) {
			cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}