Problem: Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not.

You are given a segment [L; R]. Count the number of classy integers x such that L ≤ x ≤ R.

Each testcase contains several segments, for each of them you are required to solve the problem separately.

Input

The first line contains a single integer T (1 ≤ T ≤ 10^4) — the number of segments in a testcase.

Each of the next T lines contains two integers L_i and R_i (1 ≤ L_i ≤ R_i ≤ 10^{18}).

Output

Print T lines — the i-th line should contain the number of classy integers on a segment [L_i; R_i].

Example

Input

4
1 1000
1024 1024
65536 65536
999999 1000001


Output

1000
1
0
2

Solution (in PYTHON3):

Solution:
from sys import stdin
from bisect import bisect_left as bl
c=[]
def gen(n,nz):
    if len(n)>=19:
        return
    global c
    c.append(int(n))
    if nz==3:
        n+="0"
        gen(n,nz)
        return
    gen(n+"0",nz)
    for i in ("123456789"):
        gen(n+i,nz+1)
for i in ("123456789"):
    gen(i,1)
c.append(10**18)
c.sort()
n=int(input())
for i in range(n):
    a,b=map(int,stdin.readline().strip().split())
    x=min(bl(c,b),len(c)-1)
    y=bl(c,a)
    if x==y and b<c[x]:
        print(0)
    elif (c[x]==b and c[y]==a) or c[x]==b:
        print(x-y+1)
    else:
        print(x-y)