12678 - Count 1s   

Description

Given two number a,b.

You need to calculate how many 1 appear in range a~b(decimal representation).

 

 

 

Example:

Given a = 1, b = 11.

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11

There're four 1 appear in range 1~11(1, 10, 11).

The answer is 4.

 

 

 

Input

First line contains one integer t(1 <= t <= 10^6) which means the number of testcases.

The following t lines, each line contains two integer a, b( 1 <= a <= b <= 10^6)

 

Output

For each testcase print only one number which means the number of 1 appear in range a~b.

Remember to print \n at the end of output.

Sample Input  Download

Sample Output  Download

Tags

123 456 666 9487 59420



Discuss