The “Hanoi Towers” puzzle consists of three pegs (that we will name *A*, *B*, and *C*) with *n* disks of different diameters stacked onto the pegs. Initially all disks are stacked onto peg *A* with the smallest disk at the top and the largest one at the bottom, so that they form a conical shape on peg *A*.

The input file contains two lines. The first line consists of a single integer number *n* (1 ≤ *n* ≤ 30) — the number of disks in the puzzle. The second line contains descriptions of six moves separated by spaces — the strategy that is used to solve the puzzle.

提交代码