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.InputMismatchException;
import java.io.IOException;
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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long[] z = new long[1000_000];
            int cnt = 0;
            long[] p = new long[19];
            p[0] = 1;
            for (int i = 1; i < p.length; i++) {
                p[i] = p[i - 1] * 10;
            }

            for (int i = 0; i <= 17; i++) {
                for (int di = 1; di <= 9; di++) {
                    z[cnt++] = di * p[i];
                    for (int j = 0; j < i; j++) {
                        for (int dj = 1; dj <= 9; dj++) {
                            z[cnt++] = di * p[i] + dj * p[j];
                            for (int k = 0; k < j; k++) {
                                for (int dk = 1; dk <= 9; dk++) {
                                    z[cnt++] = di * p[i] + dj * p[j] + dk * p[k];
                                }
                            }
                        }
                    }
                }
            }

            z[cnt++] = 1000_000_000_000_000_000L;
            z[cnt++] = 0;

            Arrays.sort(z, 0, cnt);

            int T = in.nextInt();
            for (int i = 0; i < T; i++) {
                long l = Long.parseLong(in.next());
                long r = Long.parseLong(in.next());

                long res = f(r, z, cnt) - f(l - 1, z, cnt);
                out.println(res);
            }
        }

        static long f(long x, long[] z, int cnt) {
            int res = Arrays.binarySearch(z, 0, cnt, x);
            return res < 0 ? -(res + 1) - 1 : res;
        }

    }

    static class InputReader {
        final InputStream is;
        final byte[] buf = new byte[1024];
        int pos;
        int size;

        public InputReader(InputStream is) {
            this.is = is;
        }

        public int nextInt() {
            int c = read();
            while (isWhitespace(c))
                c = read();
            int sign = 1;
            if (c == '-') {
                sign = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = read();
            } while (!isWhitespace(c));
            return res * sign;
        }

        public String next() {
            int c = read();
            while (isWhitespace(c))
                c = read();
            StringBuilder sb = new StringBuilder();
            do {
                sb.append((char) c);
                c = read();
            } while (!isWhitespace(c));
            return sb.toString();
        }

        int read() {
            if (size == -1)
                throw new InputMismatchException();
            if (pos >= size) {
                pos = 0;
                try {
                    size = is.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (size <= 0)
                    return -1;
            }
            return buf[pos++] & 255;
        }

        static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}