#include <iostream>
#include <vector>

using namespace std;
vector<vector<int>> solve(int n){
    if(n==1){
        vector<vector<int>> v;
        v.resize(1);
        v[0].push_back(0); v[0].push_back(1);
        return v;
    }
    vector<vector<int>> u = solve(n - 1);
    vector<vector<int>> v;
    int x = (1<<n) - 1;
    v.resize(x);
    int s = 0;
    for(int i=0;i<u.size();i++){
        for(int k=0;k<2;k++){
            for(int j=0;j<u[i].size();j++){
                v[s].push_back(u[i][j]);
            }
            for(int j=0;j<u[i].size();j++){
                v[s].push_back(u[i][j]^k);
            }
            s++;
        }
    }
    for(int i=0;i<(1<<n);i++){
        if(i<(1<<(n - 1))) v[s].push_back(0);
        else v[s].push_back(1);
    }
    return v;
}

int main(){
    int i,n; cin >> n;
    vector<vector<int>> v = solve(n);
    cout << (1<<n) - 1 << endl;
    for(i=0;i<(1<<n) - 1;i++){
        for(int j: v[i]){
            if(j==0) cout << "A";
            else cout << "B";
        }
        cout << endl;
    }
}
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
inline int BIT_popcount_L(const int x){
  return __builtin_popcount(x);
}
inline int BIT_popcount_L(const long long x){
  return __builtin_popcountll(x);
}
char res[300][300];
int ok;
int ng;
int main(){
  int N;
  rd(N);
  int p;
  int i;
  int j;
  int k;
  N = (1<<N);
  for(i=(0);i<(N-1);i++){
    for(j=(0);j<(N);j++){
      res[i][j] =BIT_popcount_L(j&(i+1))% 2;
    }
  }
  for(i=(0);i<(N-1);i++){
    for(j=(0);j<(N);j++){
      res[i][j] += 'A';
    }
  }
  wt_L(N-1);
  wt_L('\n');
  for(i=(0);i<(N-1);i++){
    wt_L(res[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay version 20210103-1 [bug fixed 1]

// --- original code ---
// char res[300][300];
// int ok, ng;
// {
//   int @N, p, i, j, k;
//   N = (1<<N);
// 
//   rep(i,N-1){
//     rep(j,N) res[i][j] = BIT_popcount(j&(i+1)) % 2;
//   }
//   rep(i,N-1) rep(j,N) res[i][j] += 'A';
// 
//   // rep(i,N) rep(j,i+1,N){
//   //   ok = ng = 0;
//   //   rep(k,N-1) if(res[k][i]==res[k][j]) ok++;
//   //   rep(k,N-1) if(res[k][i]!=res[k][j]) ng++;
//   //   wt(i,j,ok,ng);
//   // }
//   
//   wt(N-1);
//   rep(i,N-1) wt(res[i]);
// }
