G

Set of Marbles

Input: Standard Input

Output: Standard Output

You have n marbles of different colors which are distributed in 2 boxes. In each move you can move one marble from one box into another. You have to move the marbles in such a way that first box contains each combination of marble sets exactly once. There are 2n combinations of marbles.

For example you have 4 marbles. Box 1 has marbles of color 1 and 3. And Box 2 has marbles of color 2 and 4. Then the solution can be as follows.

 

Steps

Box 1 marbles

Move

Box 2 marbles

1

1,3

 

2,4

2

1,2,3

Move 2 from B2 to B1

4

3

1,2,3,4

Move 4 from B2 to B1

 

4

1,2,4

Move 3 from B1 to B2

3

5

2,4

Move 1 from B1 to B2

1,3

6

2,3,4

Move 3 from B2 to B1

1

7

3,4

Move 2 from B1 to B2

1,2

8

4

Move 3 from B1 to B2

1,2,3

9

 

Move 4 from B1 to B2

1,2,3,4

10

3

Move 3 from B2 to B1

1,2,4

11

2,3

Move 2 from B2 to B1

1,4

12

2

Move 3 from B1 to B2

1,3,4

13

1,2

Move 1 from B2 to B1

3,4

14

1

Move 2 from B1 to B2

2,3,4

15

1,4

Move 4 from B2 to B1

2,3

16

1,3,4

Move 3 from B2 to B1

2

 

Input

Input contains multiple test cases. The first line of the input contains T(1≤T≤20) the number of test cases. Each test case consists of 2 lines. The first line contains n(1≤n≤10) and b1(0≤b1≤n). n is the number of marbles and b1 is the number of marbles in the first box. The next line contains b1 integer the indices of the marbles which are in the first box. All of these numbers are distinct and between 1 and n inclusive. The rest of the n-b1 marbles are in 2nd box.

 

Output

For each test case output contains 2n lines. The first 2n-1 lines contains the moves( see the sample output for formatting). The last line is blank. In case there are multiple solutions any valid solution is acceptable.

 

Sample Input                            Output for Sample Input

2

2 1

1

4 2

1 3

 

Move 2 from B2 to B1

Move 1 from B1 to B2

Move 2 from B1 to B2

 

Move 2 from B2 to B1

Move 4 from B2 to B1

Move 3 from B1 to B2

Move 1 from B1 to B2

Move 3 from B2 to B1

Move 2 from B1 to B2

Move 3 from B1 to B2

Move 4 from B1 to B2

Move 3 from B2 to B1

Move 2 from B2 to B1

Move 3 from B1 to B2

Move 1 from B2 to B1

Move 2 from B1 to B2

Move 4 from B2 to B1

Move 3 from B2 to B1

 


Problemsetter: Abdullah al Mahmud

Special Thanks: Md. Arifuzzaman Arif, Manzurur Rahman Khan