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.*;
import java.io.*;
public class Main {
    static int min[],max[],lim;
    static long dp[][][][];
    public static void main(String args[]) {
        Scanner input=new Scanner(System.in);
        int test=input.nextInt();
        for(int t=1;t<=test;t++) {
            long L=input.nextLong();
            long R=input.nextLong();
            min=new int[(""+L).length()];
            max=new int[(""+R).length()];
            long tmp=L;
            for(int i=min.length-1;i>=0;i--) {
                min[i]=(int)(tmp%10);
                tmp/=10;
            }
            tmp=R;
            for(int i=max.length-1;i>=0;i--) {
                max[i]=(int)(tmp%10);
                tmp/=10;
            }
            long ans=0;
            for(int i=min.length;i<=max.length;i++) {
                lim=i;
                dp=new long[i][4][2][2];
                fill();
                ans+=solve(0,0,(i==max.length),(i==min.length));
            }
            System.out.println(ans);
        }
    }
    public static long solve(int indx,int n_zero,boolean u_lim,boolean l_lim) {
//        System.out.println(indx+" "+n_zero+" "+u_lim+" "+l_lim);
        if(indx==lim) {
            return 1;
        }
        if(dp[indx][n_zero][u_lim?0:1][l_lim?0:1]!=-1) {
            return dp[indx][n_zero][u_lim?0:1][l_lim?0:1];
        }
        long cnt=0;
        for(int i=0;i<10;i++) {
            if(indx==0 && i==0) {
                continue;
            }
            if(n_zero==3 && i>0) {
                break;
            }
            if(l_lim && i<min[indx]) {
                continue;
            }
            if(u_lim && i>max[indx]) {
                continue;
            }
            if(l_lim && i==min[indx] && u_lim && i==max[indx]) {
                cnt+=solve(indx+1,(i!=0?n_zero+1:n_zero),true,true);
                continue;
            }
            if(l_lim && i==min[indx]) {
                cnt+=solve(indx+1,(i!=0?n_zero+1:n_zero),false,true);
                continue;
            }
            if(u_lim && i==max[indx]) {
                cnt+=solve(indx+1,(i!=0?n_zero+1:n_zero),true,false);
                continue;
            }
            cnt+=solve(indx+1,(i!=0?n_zero+1:n_zero),false,false);
        }
        dp[indx][n_zero][u_lim?0:1][l_lim?0:1]=cnt;
        return cnt;
    }
    public static void fill() {
        for(int i=0;i<dp.length;i++) {
            for(int j=0;j<dp[i].length;j++) {
                for(int k=0;k<dp[i][j].length;k++) {
                    for(int l=0;l<dp[i][j][k].length;l++) {
                        dp[i][j][k][l]=-1;
                    }
                }
            }
        }
    }
}