#include<bits/stdc++.h>
#define PI 3.141592653589793238462
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdd;
vector<string> c;
int main(){
    int n;cin>>n;
    cout<<((1<<n)-1)<<endl;
    string s="AB";
    c.push_back(s);
    for(int i=2;i<=n;i++){
        vector<string> d;
        for(auto j:c){
            d.push_back(j+j);
            string p="";
            for(int k=0;k<j.length();k++){
                if(j[k]=='A') p+='B';
                else p+='A';
            }
            d.push_back(j+p);
        }
        string t="";
        for(int k=1;k<=(1<<(i-1));k++){
            t+='A';
        }
        for(int k=1;k<=(1<<(i-1));k++){
            t+='B';
        }
        d.push_back(t);
        c=d;
    }
    for(auto i:c){
        cout<<i<<endl;
    }
}
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
//#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod= 998244353;
long double pi = acosl(-1);
const ll infl = 8e18+5;
const int inf = 1e9+2;
const int nmax = 5e3+5;
//const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;


int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n;
    cin>>n;
    vector<string>ans;
    for(int i=1; i<(1<<n); i++){
        string s;
        for(int j=1; j<=(1<<n); j++){
            if( __builtin_popcount(i&j)&1 ) s+='A';
            else s+='B';
        }
        ans.push_back(s);
    }

    cout<<ans.size()<<"\n";
    for(auto z : ans) cout<<z<<"\n";
}
/*
*/
