#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define trace(...) debug(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void debug(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void debug(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " | ";
  debug(comma + 1, args...);
}
#define mp(x,y) make_pair(x,y)
const int INF=1000000000+5;
const int N=2e5+5;
const int M=3e5+5;
const ll oo=1e18+5;
const ll mod=998244353;



int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	vector<string> ans;	
	cin>>n;
	ans.push_back("AB");
	for(int i=1;i<n;++i){
		vector<string> tmp;
		for(string s:ans){
			tmp.push_back(s+s);
			string newS=s;
			for(char ch:s){
				if(ch=='A') newS+='B';
				else newS+='A';
			}
			tmp.push_back(newS);
		}
		string def;
		for(int j=0;j<(1<<i);++j) def+='A';
		for(int j=0;j<(1<<i);++j) def+='B';
		tmp.push_back(def);
		ans=tmp;
	}
	cout<<(int)ans.size()<<endl;
	for(string x:ans) cout<<x<<endl;
	return 0;	 
}



#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define each(e, v) for(auto &e: v)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct io_setup{
    io_setup(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

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

    if(N == 1){
        cout << "1\n";
        cout << "AB\n";
        return 0;
    }

    vector<vector<int>> now(1, vector<int>(1, 1));
    rep(i, N){
        int n = sz(now);
        vector<vector<int>> tmp(2*n, vector<int>(2*n));
        rep(i, n){
            rep(j, n){
                tmp[i][j] = now[i][j];
                tmp[n+i][j] = now[i][j];
                tmp[i][n+j] = now[i][j];
                tmp[n+i][n+j] = -now[i][j];
            }
        }
        swap(now, tmp);
    }

    cout << (1<<N)-1 << '\n';
    rep2(i, 1, sz(now)-1){
        each(e, now[i]){
            cout << (e == 1? 'A' : 'B');
        }
        cout << '\n';
    }
}