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:
#[int(k) for k in raw_input().split(" ")]

C=[[0 for j in range(50+3)] for i in range(50)]
C[0][0]=1

for i in range(1,50):
    for j in range(i+1):
        C[i][j]=C[i-1][j]+C[i-1][j-1]



def a(n,k): #numbers with n digits of which exactly k are not 0
    if not k:
        return 1
    if k>n:
        return 0
    return C[n][k]*(9**k)

A=[[a(i,j) for j in range(4)] for i in range(20)]


def b(sn,k):
    ln=len(sn)
    #print sn,ln,k
    if sn[0]!="0":
        return A[ln-1][k]+ (((int(sn[0])-1)*A[ln-1][k-1]+ (b(sn[1:],k-1) if ln>1 else (1 if k==1 else 0))) if k>0 else 0)
    else:
        return b(sn[1:],k) if ln>1 else (1 if not k else 0)

q=[int(k) for k in raw_input().split(" ")][0]
for i in range(q):
    l,r=[int(k) for k in raw_input().split(" ")]
    sl=str(l-1)
    rl=b(sl,3)+b(sl,2)+b(sl,1)
    sr=str(r)
    rr=b(sr,3)+b(sr,2)+b(sr,1)
    print rr-rl


##def nbd(n):
##    if not n:
##        return 0
##    if n%10:
##        return 1+nbd(n/10)
##    else:
##        return nbd(n/10)
##
##nbm3=0
##for i in range(1,100000):
##    nbm3+=1 if nbd(i)<=3 else 0
##    assert(nbm3==b(str(i),3)+b(str(i),2)+b(str(i),1))
##    #print nbm3,b(str(i),3)+b(str(i),2)+b(str(i),1)