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();
            
            long[][][] dp = new long[20][5][2];
            for(long[][] matrix : dp)
            {
                for(long[] arr : matrix)
                {
                    Arrays.fill(arr , -1);
                }
            }

            long val1 = solve(dp, Long.toString(r), 0, 0, 1);

            dp = new long[20][5][2];
            for(long[][] matrix : dp)
            {
                for(long[] arr : matrix)
                {
                    Arrays.fill(arr , -1);
                }
            }
            long val2 = solve(dp, Long.toString(l - 1), 0, 0, 1);

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

            t--;
        }
    }    

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

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

        long ans = 0;
        long end = tight == 1 ? s.charAt(pos) - '0' : 9;
        
        for(int dig=0; dig<=end; dig++)
        {
            int cntupd = cnt + (dig!=0 ? 1 : 0);
            
            if(cntupd <= 3)
            {
                int tightupd = tight & (dig == end ? 1 : 0);
                ans += solve(dp, s, pos+1, cntupd, tightupd);
            }
        }

        return dp[pos][cnt][tight] = 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;
        }
    }
}