

Input: 'L' = 9 , ‘R’ = 12
Output: "2"
As ‘9’ and ‘11’ are the only numbers that have their first digit equal to the last digit. So the answer is ‘2’.
The first line will contain the integer 'T', denoting the number of test cases.
Each test case contains two space-separated integers ‘L’ and ‘R’.
For each test case, print the number of integers in [L, R] such that their first digit is equal to the last digit in those integers.
You don't need to print anything. It has already been taken care of. Just implement the given function.
1 <= 'T' <= 1000
1 <= ‘L’ <= ‘R’ <= 10^18
Time Limit: 1 sec
We will calculate answers for [1, L-1] and from [1,R] and will subtract answer( [1,R] )-answer( [1,L-1] ) to get final answer.
Let's see how we will calculate answers from 1 to ‘N’.
For ‘N’ >= 10: We know that for 10 consecutive digits the least significant digit changes ‘10’ times (0 to 9) and it will definitely match ‘1’ time with the most significant digit. And for the last ‘10’ numbers the first digit will match the last digit only if last_digit>=first_digit in the number ‘N’.
So if we have to find the answer from ‘1’ to ‘N’ then the answer will be simply = N/10 + (8 + (last digit >= first digit)).
Return ‘equalTillN(r)-equaltillN(l-1)’