//Grzegorz Wierzowiecki 2005
//Generujemy wszystkie możliwe dopuszczalne ustawienia bloczków Dla danej n.

#include <iostream>
#include <string>
#include <list>
#include <set>

typedef unsigned long int ULI;

using std::set;
using std::string;
using std::cin;
using std::cout;
using std::list;

int main(){
	ULI i,j,k,n, w;
	string str;
	set<string> S;
	set<string>::iterator it;
	list<string> L;
	bool end;
	
	cin>>n;

	str = "__";
	for(i=0; i<n; i++) str = str + "A";
	for(i=0; i<n; i++) str = str + "B";
	//cout << str <<"\n"; return 0;
	S.insert( str );
	
	end = false;
	while( ! end ){
//cout << "for \n" ;
		for( it = S.begin() ; it != S.end(); ++it ){
			str = *it;
//cout << str <<"\n"; 
			for(i=0; i<(2*n+1) ; ++i)
				if( str[i] == '_' && str[i+1] == '_' ){
					w = i; //WOLNE !!!
					break;
				};
//cout << str << "   wolne: " << w << "\n";						
			for(i=0; i<(2*n+1) ; ++i){
				str = (*it);
				if( i != w-1 && i != w && i != w+1 ){
					str[w  ] = str[i];
					str[w+1] = str[i+1];
					str[i] = str[i+1] = '_';
				};
				if( S.find( str ) == S.end() ){
//cout << "       nowe: " << str << " i = " << i << "\n";
					L.push_back( str );
				};
			};
		};
//cout << "L -> empting \n" ;
		if( L.empty() ) end = true;
		while( ! L.empty() ){
			str = *(L.begin()) ;
//cout << "L.e   <   " << str <<"\n"; 
			L.pop_front();
			if( S.find( str ) == S.end() )
				S.insert( str );
		}
	};
	for( it = S.begin(); it != S.end(); ++it ){
		cout << n << " " << (*it) << "\n";
	};
	return 0;
};

