#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  int M = 1 << N;
  cout << (M - 1) << endl;

  for (int i = 0; i < (M - 1); i++) {
    string s(M, '.');

    for (int a = 0; a < M; a++) {
      if (__builtin_popcount((a & (1+i))&(M-1)) % 2 == 0)
            s[a] = 'A';
          else
            s[a] = 'B';
    }


    cout << s << endl;
  }

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

vector<string> f(ll N) {
    if(N == 1) {
        return {"AB"};
    }
    auto v = f(N - 1);
    vector<string> ret;
    for(int i = 0; i < v.size(); i++) {
        auto tmp = v[i] + v[i];
        ret.push_back(tmp);
    }
    for(int i = 0; i < v.size(); i++) {
        auto tmp = v[i];
        for(auto &c: tmp) {
            if(c == 'A') c = 'B';
            else c = 'A';
        }
        tmp += v[i];
        ret.push_back(tmp);
    }
    string S;
    for(int i = 0; i < (1 << N) / 2; i++) S.push_back('A');
    for(int i = 0; i < (1 << N) / 2; i++) S.push_back('B');
    ret.push_back(S);
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    auto ans = f(N);
    cout << ans.size() << endl;
    for(auto s : ans) cout << s << endl;
    return 0;
}