Third qualification round completed


Show one task per page / all tasks on one page

"C" A Bit Palindromic Numbers
Time limit 1 second
Memory limit 256 megabytes

Let us call the integer number a bit palindromic, if its first digit is the same as its last digit. We use decimal notation without leading zeroes. Your task is to count how many a bit palindromic numbers are there between l and r, inclusive.

The following numbers are a bit palindromic in the first sample test: 8, 9, 11, and 22.

The numbers in the second sample test — 1251 and 1261.

Input format

Input data contains multiple test cases. The first line contains one integer t — the number of test cases (1 ≤ t ≤ 5·104).

Each test case is described by a single line that contains two integers: l and r (1 ≤ l ≤ r ≤ 1018).

Output format

For each test case output one integer: how many a bit palindromic numbers are there in the given range.

Input data
8 25
1251 1266
12 21
Output data

Send solution

Upload Maximal size is 256kb

Log in

VK Facebook

Forgot password?


The instruction for password recovery
has been sent to your email