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 PYTHON):

Solution:

import sys, bisect, heapq, math
sys.setrecursionlimit(10**9+7)
def fi(): return int(sys.stdin.readline())
def fi2(): return map(int, sys.stdin.readline().split())
def fi3(): return sys.stdin.readline().rstrip()
def fo(*args):
    for s in args: sys.stdout.write(str(s)+' ')
    sys.stdout.write('\n')
##    sys.stdout.flush()
def puts(*args):
    for s in args: sys.stdout.write(str(s))
OUT = []
def bfo(*args):
    for s in args: OUT.append(str(s)+' ')
    OUT.append('\n')
def bputs(*args):
    for s in args: OUT.append(str(s))        
def flush():
    sto = ''.join(OUT); fo(sto)
##
alpha = 'abcdefghijklmnopqrstuvwxyz'; mod = 10**9+7; inf = int(2e18+5) ; nax = 101010
##

def bf(x):
    res = 0
    for i in range(x):
        s = str(i)
        d = s.count('0')
        if len(s)-d <= 3:
            res += 1
    return res

def f3(d):
    res = 1
    res += 9*d
    res = res + 36*d*(d-1) + (9*d*(d-1))/2
    res = res + 3*4*7*(d)*(d-1)*(d-2) + 9*4*d*(d-1)*(d-2) + (9*d*(d-1)*(d-2))/6
    return res

def f0(d):
    return 1

def f1(d):
    res = 1
    res += 9*d 
    return res

def f2(d):
    res = 1
    res += 9*d
    res = res + 36*d*(d-1) + (9*d*(d-1))/2
    return res
    

def g(n):
    s = str(n)
    arr = []
    for i in range(len(s)):
        arr.append(int(s[i]))

    res = 0
    d = len(s)

    F = [f3, f2, f1, f0]
    j = 0
    
    for i in range(len(arr)):
            
        if(j == 4): break

        if(arr[i] != 0):
            res += F[j](d-1-i)
            if(j < 3): res += (arr[i]-1)*F[j+1](d-1-i)
            
            j += 1
            
        else:
            pass

    return res

t = fi()

while(t):
    t-=1
    l, r = fi2()
    res = g(r+1)-g(l)
    bfo(res)


flush()