Fewest Factors

You will be given some decimal digits. Build an integer with the minimum possible number of factors, using each of the digits exactly once (be sure to count all factors, not only the prime factors). If more than one number has the same (minimum) number of factors, return the smallest one among them. You can use 0 as a leading digits if you want.

Input

The input file will contain, on the first line, a number (between 1 and 100) that equals the number of test cases.

Each test cases is given in it's own line, and consist of a series of integers seperated by spaces, representing the digits. There will be at most five digits per line.

Output

For each test case, output the desired number as described above.

Sample Input

6
1 2
6 0
4 7 4
1 3 7 9
7 5 4 3 6
1 2 4

Sample Output

21
6
447
1973
36457
241