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.io.*;
import java.util.*; 
public class GFG{ 

    static long mod = 998244353;
    static PrintWriter out = new PrintWriter(System.out);
    static long DP[][][];
    static int count(long num){
                   int c=0;
                     while(num>0)
                       { c++; num=num/10;}
                     return(c);
               }  
     static int cc=0;
    static long Calc(int a[],int pos,int flag,int k){
                             if(k>3)
                                return(0);

                             if(pos==a.length)
                                return(1);    

                             if(DP[pos][flag][k]!=-1)
                                   {  return(DP[pos][flag][k]);}

                             long ans=0;
                             int LMT = a[pos];
                             if(flag==1)
                                  LMT=9;

                              for(int i=0;i<=LMT;i++){
                                       int rr =k;
                                         if(i!=0)
                                            rr++;
                                     if(flag==1||i<LMT)
                                         ans=ans+Calc(a,pos+1,1,rr);
                                     else
                                         ans=ans+Calc(a,pos+1,0,rr);
                               }
                             DP[pos][flag][k]=ans;
                               return(ans);
                      }       
    static long solve(long n){

                   int c= count(n);
                   int ar[] = new int[c];
                   int i1=0;
                      while(n>0){
                           ar[c-1-i1++]=(int)(n%10);
                           n=n/10;
                       } 
                  
                       DP = new long[c][2][4];
                        for(int i=0;i<c;i++)
                            for(int j=0;j<2;j++)
                               for(int K=0;K<4;K++)
                                  DP[i][j][K]=-1; 
                       // System.out.println("sonu singh");
                    return (Calc(ar,0,0,0)); 
           }
    public static void main(String[] args){ 

        FastReader sc=new FastReader(); 

              int t = sc.nextInt();
           for(int sp=1;sp<=t;sp++){
              long l = sc.nextLong();
              long r = sc.nextLong();
        
                 long ansR = solve(r);
                 long ansL = solve(l-1);
                 long ans = ansR-ansL;
                /// out.println(" R :"+ansR+" L:"+ansL);
                 out.println(ans);
             }
                 out.flush();
    } 
         static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}