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 MyClass
{
    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; 
        } 
    }
    static class Pair implements Comparable<Pair>
    {
        int f,s;
        Pair(int f,int s)
        {
            this.f=f;
            this.s=s;
        }
        public int compareTo(Pair p)
        {
            return this.f-p.f;
        }
    }
    public static long go(long a[][][],char c[],int p,int tight,int cnt)
    {
        if(cnt>3)return 0L;
        if(p==-1)
        return 1L;
        if(a[p][cnt][tight]!=-1)
        return a[p][cnt][tight];
        int lim=c[p]-'0';
        if(tight!=1)
        lim=9;
        long res=0L;
        for(int i=0;i<=lim;i++)
        {
            int temp=0;
            if(i!=0)
            temp=1;
            if(i==lim)
            {
                if(tight==1)
                res+=go(a,c,p-1,1,cnt+temp);
                else
                res+=go(a,c,p-1,0,cnt+temp);
            }
            else
            res+=go(a,c,p-1,0,cnt+temp);
        }
        return a[p][cnt][tight]=res;
    }
    public static void main(String args[])
    {
        FastReader fs=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int tc=fs.nextInt();
        while(tc-->0)
        {
            long l=fs.nextLong();
            long r=fs.nextLong();
            l--;
            long a[][][]=new long[20][5][2];
            for(int i=0;i<20;i++)
            {
                for(int j=0;j<5;j++)
                Arrays.fill(a[i][j],-1);
            }
            StringBuffer sb=new StringBuffer();
            long temp=r;
            while(temp>0)
            {
                sb.append(temp%10);
                temp/=10;
            }
            char c[]=sb.toString().toCharArray();
            long rres=go(a,c,c.length-1,1,0);
            for(int i=0;i<20;i++)
            {
                for(int j=0;j<5;j++)
                Arrays.fill(a[i][j],-1);
            }
            sb=new StringBuffer();
            temp=l;
            while(temp>0)
            {
                sb.append(temp%10);
                temp/=10;
            }
            c=sb.toString().toCharArray();
            long lres=go(a,c,c.length-1,1,0);
            pw.println(rres-lres);
        }
        pw.flush();
        pw.close();
    }
}