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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()

string F(string a){//aのAとBを反転させたやつを返す
  for(auto &p:a)
    if(p=='A')p='B';
    else p='A';
  return a;
}

int G(int a){
  return (1<<a)-1;
}

int main(){
  int n;cin>>n;
  vector<vector<string>> s(n+1);//s[i]:n=iの時の答え
  for(int i=1;i<=n;i++)s[i].resize(G(i));
  s[1][0]="AB";
  for(int i=2;i<=n;i++){
    REP(j,G(i-1)){
      s[i][j]       =s[i-1][j]+F(s[i-1][j]);
      s[i][G(i-1)+j]=s[i-1][j]+  s[i-1][j];
    }
    s[i].back()=string(1<<(i-1),'A')+string(1<<(i-1),'B');
  }
  cout<<s[n].size()<<endl;
  for(string p:s[n])cout<<p<<endl;
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
ll I=167167167167167167;
ll Q=1e9+7;

string han(string S){
	string T;
	for(int i=0;i<S.size();i++){
		if(S[i]=='A') T+="B";
		else T+="A";
	}
	return T;
}

int main() {
	ll N,A=1;
	cin>>N;
	vector<string> p;
	for(int i=0;i<N;i++){
		A*=2;
		vector<string> q;
		string T;
		for(int j=0;j<A;j++){
			if(j*2<A) T+="A";
			else T+="B";
		}
		q.push_back(T);
		for(auto x:p){
			q.push_back(x+x);
			q.push_back(x+han(x));
		}
		p=q;
	}	
	cout<<A-1<<endl;
	for(auto x:p) cout<<x<<endl;
}
