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 CF1036_C {
    public static void main(String[] args) throws Throwable {
        MyScanner sc = new MyScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int t = sc.nextInt();
        while (t-- > 0) {
            long x = sc.nextLong();
            String s = x + "";
            while (s.length() < 65)
                s = "0" + s;
            l = s.toCharArray();
            long y = sc.nextLong();
            s = y + "";
            while (s.length() < 65)
                s = "0" + s;
            r = s.toCharArray();
            mem = new Long[70][2][2][4];
            pw.println(dp(0, 0, 0, 0));

        }


        pw.flush();
        pw.close();
    }

    static char[] l, r;
    static Long[][][][] mem;

    static long dp(int i, int j, int k, int c) {
        if (i == l.length)
            return 1;
        if (mem[i][j][k][c] != null)
            return mem[i][j][k][c];
        long ans = 0;
        for (char cur = '0'; cur <= '9'; cur++) {
            if (j == 0 && cur < l[i])
                continue;
            if (k == 0 && cur > r[i])
                continue;
            if (cur != '0' && c == 3)
                continue;
            ans += dp(i + 1, j == 1 ? j : cur > l[i] ? 1 : 0, k == 1 ? 1 : cur < r[i] ? 1 : 0, c + (cur != '0' ? 1 : 0));
        }

        return mem[i][j][k][c] = ans;
    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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;
        }
    }
}