#include<bits/stdc++.h>
using namespace std;
int f(int n,char q,char w,char o){
	if(n==1) cout<<q<<" "<<"To"<<" "<<o<<endl;
	else{
		f(n-1,q,o,w);
		cout<<q<<" "<<"To"<<" "<<o<<endl;
		f(n-1,w,q,o);
	} 
}
int main(){
	int n;
	cin>>n;
	f(n,'A','B','C');
	return 0;
}

/**************************************************************
	Problem: 1222
	User: houshanglin
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:2072 kb
****************************************************************/