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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CClassyNumbers solver = new CClassyNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class CClassyNumbers {
        static char[] min;
        static char[] max;
        static int lastIdx;
        static Long[][][][] memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int q = sc.nextInt();
            while (q-- > 0) {
                String temp = sc.next();
                max = sc.next().toCharArray();
                min = new char[max.length];
                Arrays.fill(min, '0');
                for (int i = temp.length() - 1, j = max.length - 1; i >= 0; i--, j--) {
                    min[j] = temp.charAt(i);
                    lastIdx = j;
                }
                memo = new Long[2][2][4][max.length];
                pw.println(dp(0, 0, 0, 3));
            }
        }

        private long dp(int idx, int b, int s, int k) {
            if (k < 0)
                return 0;
            if (idx == max.length)
                return 1;
            if (memo[b][s][k][idx] != null)
                return memo[b][s][k][idx];
            boolean big = b == 1, small = s == 1;
            int start = big ? 0 : min[idx] - '0';
            int end = small ? 9 : max[idx] - '0';
            long sum = 0;
            for (int i = start; i <= end; i++) {
                sum += dp(idx + 1, i > min[idx] - '0' ? 1 : b, i < max[idx] - '0' ? 1 : s, i != 0 ? k - 1 : k);
            }
            return memo[b][s][k][idx] = sum;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

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

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}