eolymp
bolt
Try our new interface for solving problems
Problems

Towers of Hanoi

Towers of Hanoi

Three pegs are given. The first peg contains some disks in ascending order of their size from top to bottom. The other two pegs are empty. You must move all disks from the first peg to the second. You can move each time only one disk. It is not allowed to put a larger disk on a smaller one. \includegraphics{https://static.e-olymp.com/content/31/31f5c1916c2b8221f358c14586f64a02959f3bb2.gif} \InputFile The number of disks $n~(1 \le n \le 19)$ on the first peg. \OutputFile In each line print two numbers --- the peg numbers from which and where the disk is moved. The solution must be the shortest.
Time limit 3 seconds
Memory limit 128 MiB
Input example #1
3
Output example #1
1 2
1 3
2 3
1 2
3 1
3 2
1 2