3 // number of testcase
123 1 // number cards, the number of exchange
2737 1 // number cards, the number of exchange
32888 2
-----
Case #1
321
Case #2
7732
Case #3
88832
-----------
50
772 8
441296 9
5525 2
114 2
6575 3
0473 7
7321 10
1138 4
53179 9
975054 4
0128 9
50665 7
937 2
55960 5
564 9
50308 8
57308 6
215 4
377088 3
340 1
1136 6
37 2
58 8
1375 8
655673 10
29 4
153 3
583185 8
812 7
361 9
394 5
60153 1
65433 4
267825 10
969 9
027147 10
08343 8
57568 1
805683 8
83 8
97 9
7734 5
5005 7
216926 7
3560 7
50 1
679 9
16813 3
1415 8
751 10