#P7791. X Number
X Number
X Number
Problem Description
Teitoku loves many different kinds of numbers, and today Little W wants him to classify some positive integers into different categories. There are categories, numbered from to . For each positive integer , if there exists only one type of digit that occurs in with the highest frequency, then we say should be classified into category , or otherwise, in case such digit doesn't exist, we say should be classified into category . For example, ● should be classified into category since digit occurs three times, and digits and occur less than three times respectively, and ● should be classified into category since digit occurs three times, and digits and occur less than three times respectively, and ● should be classified into category since digits , and occur twice respectively. Little W doesn't care about category and he just wants Teitoku to tell him the number of integers ranged from to that should be classified to another category . However, Teitoku can hardly solve this problem, so he asks you for help.
Input
There are several test cases. The first line contains an integer , denoting the number of test cases. Then follow all the test cases. For each test case, the only line contains three integers , and , representing a problem.
Output
For each test case, output in one line the number of integers ranged from to that should be classified to category .
Sample Input
3
1 10 1
1 11 1
1 100 0
Sample Output
1
2
1
Hint
For the sample cases, 1 and 11 are in category 1, 100 is in category 0 and 10 is in category 10.
Source
2020 Multi-University Training Contest 3