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 
{
    public static void main(String[] args) 
    {
        FastReader scn = new FastReader();
        int t = scn.nextInt();

        while(t > 0)
        {
            long l = scn.nextLong();
            long r = scn.nextLong();
            
            initialiseDP();
            initialiseS(r);
            long val1 = solve(0, 1, 0);

            initialiseDP();
            initialiseS(l - 1);
            long val2 = solve(0, 1, 0);

            long ans = val1 - val2;
            System.out.println(ans);

            t--;
        }
    }    

    public static long[][][] dp;
    public static String s;

    public static void initialiseDP()
    {
        dp = new long[19][2][4];

        for(long[][] matrix : dp)
        {
            for(long[] arr : matrix)
            {
                Arrays.fill(arr , -1);
            }
        }
    }

    public static void initialiseS(long n)
    {
        s = Long.toString(n);
    }

    public static long solve(int pos, int tight, int cnt)
    {
        if(pos == s.length()) return 1;

        if(dp[pos][tight][cnt] != -1) return dp[pos][tight][cnt];

        long ans = 0;

        long end = tight == 1 ? s.charAt(pos) - '0' : 9;
        
        for(int dig=0; dig<=end; dig++)
        {
            int posupd = pos + 1;

            int cntupd = cnt;
            if(dig != 0) cntupd++;
            
            int tightupd = tight & (dig == end ? 1 : 0);

            if(cntupd <= 3)
            {
                ans += solve(pos+1, tightupd, cntupd);
            }
        }

        return dp[pos][tight][cnt] = ans;
    }

    public 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;
        }
    }
}