A number is a "Noora" number if the count of distinct digits of the number is equal to the maximum digit of the number. So, 123 is a Noora number but 124 is not. Some of the first Noora numbers are 1, 11, 12, 20, 21, 103, 111, 112, ....
Given , you have to tell how many Noora numbers are smaller or equal to .
Input starts with an integer (), denoting the number of test cases. Each case contains an integer ().
For each test case, output the number of Noora numbers that are smaller or equal to .
Input | Output |
---|---|
5 10 100 1000 10000 100000 | 1 5 29 213 1893 |