abc

Ram is playing a game with you in which you both have some equal random blocks on which a number between 0 to 9 is printed on  it.
Points are given on the basis of the number one has made. For example if you had 5 blocks (2,9,1,5,5) the largest number you can make is 95521 and smallest numbers you can make is 12559.
Now given the blocks your task is determine the lowest positive number ( hint: 0 is not considered as positve :) ) that you cannot make from the given blocks. For example the smallest number you cannot make from (2,9,1,5,5) is 3 since you dont have block 3.

SAMPLE INPUT
Input will be of the format:
T
a0 a1 a2 a3 a4 a5 a6 a7 a8 a9
b0 b1 b2 b3 b4 b5 b6 b7 b8 b9
.
.
(...T times)
where T is the no. of test cases (T ≤ 100) followed by T lines each having 10 space seperated numbers on a new line, a(i) represents the number of blocks on which i is printed.

SAMPLE OUTPUT
For each test case, you have to output a single positive number that cannot be made from the blocks given.

Sample input
3
6 5 2 1 2 3 9 0 3 1
1 2 1 3 1 4 1 5 1 6
0 2 1 1 2 1 3 4 0 0

Sample output
7
22
20

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY
Tags: Data structures


Solutions: