Limits 2s, 1.0 GB

Miss Abida a tech-smart student. Her friend M.Roy developed a social media site bugbook.com. Miss Abida has found a bug on that site. She notices that to crack another bugbook account need a recovery code. She has generated some recovery code. Then she has found a pattern. The pattern is every recovery code has at least one digit with at least 3 times. Example of recovery code: 1211(1 three times), 1112223 (1 and 2 three times), 45345444 (4 five times). But 112233 is not a valid recovery code.
Now she is thinking about how to count all the recovery code. As, you are a programmer, you want to help her.
You are given a range of integer L to R. And you have to find how many numbers in the range L to R (L and R included) which have at least one digit with at least 3 times.

Input

Input starts with the number of test case T. Each case contains two integer L and R.

Constrains:
1<=T<=10
1<=L<=R<=2^31

Output

For each test case print required answer.

Sample

InputOutput
2
1 1000
300 333
10
1

Submit

Login to submit.

Statistics

0% Solution Ratio
Toph uses cookies. By continuing you agree to our Cookie Policy.