Palindromic Numbers#6288

Palindromic Numbers

2 seconds
256 megabytes
Easy

Vasya enjoys exploring various intriguing classes of numbers, and today he is delving into palindromic numbers.

A number is termed palindromic by Vasya if it reads the same forwards and backwards. Additionally, Vasya permits the addition of several (possibly zero) leading zeros to the number. For instance, the numbers , , , and are considered palindromic. Specifically, the number becomes with the addition of a leading zero, making it read the same from both directions.

Vasya is particularly interested in palindromic numbers that differ by . For his study, he looks for numbers such that both x-1 and x+1 are palindromic. He refers to these numbers as inter-palindromic. Vasya seeks to determine the count of inter-palindromic numbers within the range from L_k to R_k, inclusive, for several specified segments [L_k, R_k].

Assist Vasya with this intriguing task!

Input

The input file contains several segments of interest to Vasya. The first line contains a single integer (1 \le T \le 2000) — the number of segments. Each of the following lines contains two integers L_k and R_k (1 \le L_k \le R_k \le 10^{18}) — the boundaries of the segment.

Output

Output lines. On the -th line, output a single integer — the count of inter-palindromic numbers in the segment from L_k to R_k, inclusive.

Explanation of the example: Between and , the palindromic numbers are and . Thus, the only inter-palindromic number in the segment is . In the second example, the number is valid again. Between and , the palindromic numbers are and . There are no inter-palindromic numbers in the segment .

Examples

Example 1

Loading
Loading