Skip to content
UPEEC

Tower of Hanoi

Medium#recursion· solved by 0 · time limit 2.0 s

Move nn discs from rod A to rod C using rod B, never placing a bigger disc on a smaller one. Print the minimum number of moves, then each move as from to, using the standard recursive solution.

Input

A single integer nn.

Output

The number of moves, then one move per line.

Constraints

1≤n≤101 \le n \le 10

Sample 1

Input

2

Output

3
A B
A C
B C

Sign in or join free to run and submit your solution.