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
 */
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 = new long[20][20][2];

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.ni();
            while (t-- > 0) {
                for (int i = 0; i < 20; ++i)
                    for (int j = 0; j < 20; ++j)
                        for (int k = 0; k < 2; ++k) dp[i][j][k] = -1L;
                long a = in.nl() - 1L;
                String x1 = Long.toString(a);
                //out.println(x1);
                long ans1 = solve(x1, 0, 0, 0);
                for (int i = 0; i < 20; ++i)
                    for (int j = 0; j < 20; ++j)
                        for (int k = 0; k < 2; ++k) dp[i][j][k] = -1L;
                String x2 = Long.toString(in.nl());
                //out.println(x2);
                long ans2 = solve(x2, 0, 0, 0);
                out.println(ans2 - ans1);
            }
        }

        public long solve(String x, int pos, int count, int less) {
            if (count > 3) return 0L;
            if (pos == x.length()) return 1L;
            if (dp[pos][count][less] != -1L) return dp[pos][count][less];
            long ans = 0L;
            if (less == 0) {
                for (int i = 0; i <= x.charAt(pos) - '0'; ++i) {
                    ans += solve(x, pos + 1, count + (i > 0 ? 1 : 0), i < x.charAt(pos) - '0' ? 1 : 0);
                }
            } else {
                for (int i = 0; i <= 9; ++i) {
                    ans += solve(x, pos + 1, count + (i > 0 ? 1 : 0), 1);
                }
            }
            dp[pos][count][less] = ans;
            return ans;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

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

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

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

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}