#include<iostream>
using namespace std;
#include<string>
int index = 0;
void hanoi(int n,char from,char buffer,char to){
if (n == 1)
{
cout << from << "->" << to << endl;
index++;
}
else {
hanoi(n-1,from,to,buffer);//将n-1个盘子通过c从a移到b
hanoi(1, from, buffer, to);//将最大的盘子从a移到c(以b为中介)
hanoi(n-1,buffer,from,to);//将n-1个盘子从b移到c(借助a)
}
}
int main(){
int n;
while (cin >> n){
index = 0;
hanoi(n, 'A','B','C');
cout << "移动的步数是:" << index << endl;
}
}