Atul has started working as a food delivery executive for Swiggy and he needs to deliver food in a magical place called Swiggy-City where houses are numbered from to . Atul starts from house number 1. From any house number he can move to house number such that.
- or
- or
- The number can be achieved by sorting the digits of number in descending order.
Note that should be a whole number and within boundaries during any time ().
Since Atul is stressed out and wants to deliver as many food packets as possible, please help him to get to the house number from house number using a minimum number of operations.
Input Format
First line contains a single integer , denoting the number of tests.
Next lines contain two integers and , denoting the number of houses in Swiggy-City and the house number Atul wants to reach.
Constraints
Output Format
Output lines containing a single integer which is the answer for each test.
Sample Input 0
1
100 61
Sample Output 0
5
Explanation 0
Atul can reach house number from house number in the following order: . So the answer is .