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.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        long[][][] dp;
        String l;
        String r;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            for (int i = 0; i < t; i++) {
                l = String.valueOf(in.nextLong() - 1);
                r = String.valueOf(in.nextLong());
                initializeDP();
                long one = call(0, 0, 0, l);
                initializeDP();
                long two = call(0, 0, 0, r);
                out.println(two - one);
            }
        }

        private long call(int pos, int count, int isLesser, String s) {
            if (count > 3)
                return 0;
            if (pos == s.length())
                return count < 4 ? 1 : 0;
            if (dp[pos][count][isLesser] > -1)
                return dp[pos][count][isLesser];
            long res = 0;
            int lmt;
            if (isLesser == 0) {
                lmt = Integer.valueOf("" + s.charAt(pos));
            } else {
                lmt = 9;
            }
            for (int i = 0; i <= lmt; i++) {
                int isLess = isLesser;
                int cnt = count;
                if (isLesser == 0 && i < Integer.valueOf("" + s.charAt(pos)))
                    isLess = 1;
                if (i > 0)
                    cnt += 1;
                res += call(pos + 1, cnt, isLess, s);
            }
            return dp[pos][count][isLesser] = res;
        }

        private void initializeDP() {
            dp = new long[19][19][2];
            for (int i = 0; i < 19; i++)
                for (int j = 0; j < 19; j++) {
                    dp[i][j][0] = -1;
                    dp[i][j][1] = -1;
                }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}