def hanoi(n,A,B,C):
if n==1:
print(A,"To",C)
else:
hanoi(n-1,A,C,B)
print(A,"To",C)
hanoi(n-1,B,A,C)
x=int(input())
hanoi(x,"A","B","C")
/**************************************************************
Problem: 1222
User: admin
Language: Python
Result: Accepted
Time:92 ms
Memory:34480 kb
****************************************************************/