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.math.BigInteger;
import java.util.*;


public class Main {

    public static List<BigInteger> l = new ArrayList<>();


    public static void impl(StringBuilder st, int cnt) {

        if (cnt >= 4) {
            return;
        }
        if (st.length() == 19) {
            l.add(new BigInteger(st.toString()));
            return;
        }
        //
        st.append('0');

        impl(st, cnt);

        st.deleteCharAt(st.length() - 1);
        for (int i = 1; i <= 9; i++) {
            st.append(i);
            impl(st, cnt + 1);
            st.deleteCharAt(st.length() - 1);
        }

    }

    private static int lowerBound(BigInteger element) {
        int low = 0;
        int high = l.size();
        while (low < high) {
            int middle = low + (high - low) / 2;
            if (element.compareTo(l.get(middle)) == 1)
                low = middle + 1;
            else
                high = middle;
        }
        return low;
    }

    private static int upperBound(BigInteger element) {
        int low = 0;
        int high = l.size();
        while (low < high) {
            int middle = low + (high - low) / 2;
            if (element.compareTo(l.get(middle)) == -1)
                high = middle;
            else
                low = middle + 1;
        }
        return low;
    }


    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        ////////////////////////////////////////////////////////////////////////

        impl(new StringBuilder(), 0);

        Collections.sort(l);

        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            String s1 = sc.next();
            String s2 = sc.next();

            out.println( upperBound(new BigInteger(s2)) - lowerBound(new BigInteger(s1)) );

        }


        ////////////////////////////////////////////////////////////////////////
        out.flush();
        out.close();
    }


    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}