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

Solution:
import java.util.Scanner;

public class Main50C {
    public static int[] convertToArray(long x) {

        if (x==0) {
            int[] ret = new int[1];
            ret[0] = 0;
            return ret;
        }
        long tmp = x;
        int len = 0;
        while(tmp>0) {tmp = tmp/10;len++;};
        int[] ret = new int[len];
        int i = 0;
        while(x>0){
            ret[len - 1 - i ] = (int)(x % 10);
            i++;
            x = x / 10;
        }
        return ret;
    }
    public static long com(int n,int k) {
        long ans=1;
        for (int i =1;i <=k;i ++)
            ans*=(n-i+1);
        for (int i =1;i <=k;i ++)
            ans/=i;
        return ans;
    }
    public static long compute(int[] a,int k) {
        int len = a.length;
        int[] b = new int[len-1];
        if (k>len) return 0;
        if (len==1) return a[0];
        for (int i = 0;i < b.length; i ++) {
            b[i] = a[i+1];
        }
        if (a[0]==0) {

            return compute(b,k);
        }

        int tot = 0;
        for (int i =0;i < len;i ++)
            tot+=a[i];
        if (k==1) return a[0]+(len-1)*9;


        len --;
        long tmp = 1;
        for (int i =0;i < k;i ++)
            tmp*=(len-i);
        for (int i = 1;i <= k;i ++)
            tmp/=i;
        //System.out.println("tmp=="+tmp);
        return com(len,k)*(long)Math.pow(9,k)+(((a[0]-1)*com(len,k-1)*(long)Math.pow(9,k-1)))+  compute(b,k-1);
        //return len*9+a[0]+len*(len-1)/2*81+(a[0]-1)*len*9+(len-1)*9+a[1]+len*(len-1)*(len-2)/6*81*9+(a[0]-1)*(len-1)*len/2*81+(len-1)*(len-2)/2*9+(a[1]-1)*(len-1)*9+(len-2)*9+a[2];
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0) {
            long l = sc.nextLong();
            long r = sc.nextLong();
            //System.out.println(convertToArray(l));
            //System.out.println((int)((int)Math.log10(l+0.0))+1);
            int[] a = convertToArray(l-1);
            int[] b = convertToArray(r);
            //int lena = a.length,lenb = b.length;
            //(lena*9+a[0]+lena*(lena-1)/2*81+a[0])
//            System.out.println(compute(b,3));
//            System.out.println(compute(b,2));
//            System.out.println(compute(b,1));
//            System.out.println(compute(a,3));
//            System.out.println(compute(a,2));
//            System.out.println(compute(a,1));
            System.out.println((compute(b,3)+compute(b,2)+compute(b,1)) - (compute(a,3)+compute(a,2)+compute(a,1)));

        }
    }
}