#include <bits/stdc++.h>

using namespace std;

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

    cout << (1 << n) - 1 << '\n';
    for (int i = 1; i < 1 << n; ++i) {
        for (int j = 0; j < 1 << n; ++j) {
            if (__builtin_popcount(i & j) & 1) {
                cout << 'B';
            } else {
                cout << 'A';
            }
        }
        cout << '\n';
    }

	return 0;
}

#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

char buf[10][2000][2000];
int n;

int main(void) {
  scanf("%d", &n);
  buf[0][0][0] = 'A';
  buf[0][0][1] = 'B';
  REP(k, n-1) {
    REP(i, (1<<(k+1))-1) {
      REP(j, 1<<(k+1)) {
        if(buf[k][i][j] == 'A') {
          buf[k+1][2*i][j*2] = 'A';
          buf[k+1][2*i][j*2+1] = 'A';
        } else {
          buf[k+1][2*i][j*2] = 'B';
          buf[k+1][2*i][j*2+1] = 'B';
        }
      }
      // cerr << "1> " << 2*i << " " << buf[k+1][2*i] << endl;
      REP(j, 1<<(k+1)) {
        if(buf[k][i][j] == 'A') {
          buf[k+1][2*i+1][j*2] = 'A';
          buf[k+1][2*i+1][j*2+1] = 'B';
        } else {
          buf[k+1][2*i+1][j*2] = 'B';
          buf[k+1][2*i+1][j*2+1] = 'A';
        }
      }
      // cerr << "2> " << 2*i+1 << " " << buf[k+1][2*i+1] << endl;
    }
    REP(j, 1<<(k+2)) {
      buf[k+1][((1<<(k+1))-1)*2][j] = j % 2 ? 'B' : 'A';
    }
    // cerr << "3> " << ((1<<(k+1))-1)*2 << " " << buf[k+1][((1<<(k+1))-1)*2] << endl;
  }
  printf("%d\n", (1<<n)-1);
  for(int i = 0; i < (1 << n)-1; ++i) {
    puts(buf[n-1][i]);
  }
  return 0;
}
