#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

ll powe(ll a, ll b){//aのb乗のmod
  ll ret = 1;
  while(0 < b){
    if((b%2) == 0){
      a = (a*a);
      b >>= 1;
    }
    else{
      ret = (ret*a);
      b--;
    }
  }
  return ret;
}

int main(){
  vector<vector<string>> ansl(9);
  FOR(i,1,8){
    string d = "";
    REP(j,(1ll<<i-1)) d+="AB";
    ansl[i].pb(d);
  }
  FOR(i,1,7){
    REP(j,ansl[i].size()){
      string v = ansl[i][j];
      string w = "";
      string x = "";
      REP(k,v.length()){
        if (v[k]=='A') {
          w+="AA";
          x+="AB";
        }
        else {
          w+="BB";
          x+="BA";
        }
      }
      ansl[i+1].pb(w);
      ansl[i+1].pb(x);
    }
  }
  ll n; cin >> n;
  cout << ansl[n].size() << endl;
  REP(i,ansl[n].size()) {
    cout << ansl[n][i] << endl;
  }
}
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int POW[10];
char table[260];


//最大公約数
ll gcd(ll x,ll y){

	x = abs(x);
	y = abs(y);

	if(x < y){
		swap(x,y);
	}
	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}

//最小公倍数
ll lcm(ll x,ll y){

	return (x*y)/gcd(x,y);
}


int main(){

	POW[0] = 1;
	for(int i = 1; i < 10; i++){

		POW[i] = POW[i-1]*2;
	}

	int N;
	scanf("%d",&N);

	if(N == 1){

		printf("1\n");
		printf("AB\n");
		return 0;
	}

	printf("%d\n",POW[N]-1);

	for(int i = 1; i <= POW[N]-1; i++){
		for(int k = 0; k < POW[N]; k++){
			int num = __builtin_popcount(i&k);
			if(num%2 == 0){

				printf("A");
			}else{

				printf("B");
			}
		}
		printf("\n");
	}

	return 0;
}
