There are three pegs, numbered , and . On the first one sit discs of different sizes, stacked by size: the disc of size is at the bottom, the disc of size on top of it, and so on up to the disc of size at the very top. The other two pegs are empty.
Your task is to move the whole stack from peg to peg in as few moves as possible. There are two rules:
- one move takes the top disc of some peg and puts it on the top of another peg;
- a disc may never be placed on a smaller disc.
Write a program that prints the moves.
Input
First line of input will be a single integer - the number of testcases.
Each of the next lines contains a single integer - the number of discs on the first peg.
Output
For every testcase print one line per move: the number of the peg the disc is taken from and the number of the peg it is put on, separated by a single space. The moves of the testcases follow one another with nothing in between.
Example
2 3 2
1 3 1 2 3 2 1 3 2 1 2 3 1 3 1 2 1 3 2 3
The first seven lines solve : the smallest disc goes to peg , the middle one to peg , then the smallest joins it, which frees the biggest disc to move to peg - and the two discs waiting on peg follow it in three more moves. The last three lines solve .
Constraints
This problem was adapted, with permission, from Hanojske kule, authored by Društvo matematičara Srbije and Fondacija Petlja.