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.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskC {
        long[][] C = new long[20][40];
        long[] pow = new long[64];

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            for (int i = 0; i < 20; ++i) {
                C[i][0] = C[i][i] = 1;
                for (int j = 1; j < i; ++j)
                    C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
            }
            pow[0] = 1;
            pow[1] = 9;
            pow[2] = 81;
            pow[3] = 729;
            int Q = in.nextInt();
            for (int q = 0; q < Q; ++q) {
                long L = in.nextLong();
                long R = in.nextLong();
                out.println(calculate(R + 1) - calculate(L));
            }
        }

        public long calculate(long n) {
            String s = Long.toString(n);
            long ans = 0;
            int cur = 3;
            int len = s.length();
            for (int i = 0; i < len; ++i) {
                if (s.charAt(i) == '0') continue;
                ans += getSum(len - i - 1, cur);
                --cur;
                if (cur == -1) break;
                ans += getSum(len - i - 1, cur) * (s.charAt(i) - '1');
            }
            return ans;
        }

        public long getSum(int n, int r) {
            long ans = 0;
            for (int i = 0; i < r + 1; ++i) {
                ans += nCr(n, i) * pow[i];
            }
            return ans;
        }

        public long nCr(int n, int k) {
            if (k > n || k < 0) return 0;
            return C[n][k];
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

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

        public long nextLong() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

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

    }
}