TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

A digit of a decimal integer N is a local maximum if it is bigger than both of its adjacent digits. For simplicity, the first and last digits of a number are not local maximum.



Let us consider a signature of a decimal number N which is defined as the number of local maximum digits of that number. Your task is to write a program to compute the sum of signatures of all numbers in a range from X to Y inclusively.

Input Format

The input file consists of several data sets. The first line of the input file contains the number of data sets which is a positive integer and is not bigger than 50000. The following lines describe the data sets.



Each data set consists of only one line, which contains two integers X and Y separated by a space (0 ≤ X ≤ Y ≤ 1015).

Output Format

For each data set, write in one line the sum for the signatures of all numbers in the range from X to Y inclusively.

Sample Input 1

4
1 100
121 121
909 909
100 150

Sample Output 1

0
1
0
10

Hints

Problem Source

Migrated from old NTUJ.

The ACM-ICPC 2010 Asia Regional Contest, Site Hanoi

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 1600