#innclude <iostream>
using namespace std;
void h(int n,char a,char b,char c){
    if(n > 0){        h(n - 1,a,c,b);
        cout<<a<<" To "<<c<<endl;
        h(n - 1,b,a,c);        
    }
}
 
int main(){
    int n;
    cin>>n;
    h(n,'A','B','C');
}
/**************************************************************
	Problem: 1222
	User: panyuchen
	Language: C++
	Result: Compile Error
****************************************************************/