Niloufar wants to give Amin a gift after counting his birth date in calendar from begining. Help Niloufar to solve this problem.
You are given two integers and and finds the -th smallest natural number that contains the number as a subsequence.
We know that the number consists of distinct digits.
The first line of input contains a positive integer , representing the number of test cases.
In the first line of each test case, two positive integer and is given in order.
For each test case, print a single integer representing the -th smallest number that contains as a subsequence.