Set of Marbles

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 1 1,3 2 1,2,3 3 1,2,3,4 4 1,2,4 5 2,4 6 2,3,4 7 3,4 8 4 9 10 3 11 2,3 12 2 13 1,2 14 1 15 1,4 16 1,3,4 Move Move2fromB2toB1 Move4fromB2toB1 Move3fromB1toB2 Move1fromB1toB2 Move3fromB2toB1 Move2fromB1toB2 Move3fromB1toB2 Move4fromB1toB2 Move3fromB2toB1 Move2fromB2toB1 Move3fromB1toB2 Move1fromB2toB1 Move2fromB1toB2 Move4fromB2toB1 Move3fromB2toB1 Box 2 marbles 2,4 4 3 1,3 1 1,2 1,2,3 1,2,3,4 1,2,4 1,4 1,3,4 3,4 2,3,4 2,3 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 2-nd 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 2 21 1 42 13

2/2 Sample Output 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