~/algor $ cat contests/round-3/E
E. Tower of Hanoi
There are three rods numbered $1$, $2$ and $3$. Rod $1$ holds $n$ disks: the largest at the bottom, each next one smaller. All disks must be moved to rod $3$ in the fewest moves. One move takes only one disk, the top one; a larger disk may not be placed on a smaller one.
The shortest sequence of moves is unique and has $2^{n} - 1$ moves. Find from which rod to which rod the $k$-th move of this sequence goes. For example, for $n = 2$ the moves are $1 \to 2$, $1 \to 3$, $2 \to 3$.
Input
One line with two positive integers: $n$ and $k$.
Output
One line with two positive integers: the rod ($1$, $2$ or $3$) the disk is taken from and the rod it is put on in the $k$-th move.
Note
$1 \le n \le 60$
$1 \le k \le 2^{n} - 1 \lt 2^{60}$
Examples
2 1
1 2
2 3
2 3