Nick only likes numbers with exactly distinct digits. Through a mysterious process that he has coined alchemy, he can convert a positive integer to , though it is a tiring process.
For a given integer , compute the smallest integer greater than or equal to with exactly distinct digits.
Constraints
Input Specification
The first line contains a single positive integer, , the number of test cases. test cases follow.
Each test case consists of a single line that contains two space-separated positive integers, and .
Output Specification
Output the answers for the test cases in order. There should be no blank lines in your output.
The answer for the th test case should be on the th line. Output the smallest integer greater than or equal to with exactly distinct digits.
Sample Input
6
1 1
1 2
1 3
11 1
11 2
11 3
Sample Output
1
10
102
11
12
102
Comments