Wolowitz is working on a new prototype of a device to be installed at the international space station. After working for hours and taking many conditions into consideration, he has reduced the problem to a very simple math problem.
The problem states that you have to take a few numbers and taking each number is having some cost which will be equal to number of digits in that number. Also, you can't take a number lesser than N and total cost cannot exceed C. The task is to calculate the maximum count of numbers that you can take with given N and C.
Input Format:
First line contains T, number of test cases.
Each of the next T lines contains N and C, least number and total cost.
Output Format:
For each test case, output the required answer is separate lines.
Constraints:
1≤T≤10
1≤N,C≤1016
For first case, one can take {1, 2, 3, 4, 5, 6, 7, 8, 9} with total cost 9.
For second case, one can take (7, 8, 9, 10, 11, 12, 13} with total cost of 11.
For third case, one can take {5, 6, 7, 8, 9, 10} with total cost of 7. Adding one more number of 2-digits will increase cost to 9 which exceeds 8.