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.util.Collections;
import java.util.ArrayList;
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 {
        ArrayList<Long> ansList = new ArrayList<>();

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            brute(0, 0, 0);
            ansList.add(1000000000000000000L);
            Collections.sort(ansList);
            int Q = in.nextInt();
            for (int q = 0; q < Q; ++q) {
                long L = in.nextLong();
                long R = in.nextLong();
                int indL = LowerBound(ansList, L);
                int indR = UpperBound(ansList, R);
                out.println(indR - indL);
            }
        }

        void brute(int pos, int cnt, long cur) {
            if (pos == 18) {
                ansList.add(cur);
                return;
            }
            brute(pos + 1, cnt, cur * 10);
            if (cnt < 3)
                for (int i = 1; i <= 9; ++i)
                    brute(pos + 1, cnt + 1, cur * 10 + i);
        }

        public static int LowerBound(ArrayList<Long> a, long key) {
            int high = a.size();
            int low = -1;
            while (high - low > 1) {
                int mid = (high + low) >>> 1;
                if (a.get(mid) >= key) {
                    high = mid;
                } else {
                    low = mid;
                }
            }
            return high;
        }

        public static int UpperBound(ArrayList<Long> a, long key) {
            int high = a.size();
            int low = -1;
            while (high - low > 1) {
                int mid = (high + low) >>> 1;
                if (a.get(mid) > key) {
                    high = mid;
                } else {
                    low = mid;
                }
            }
            return high;
        }

    }

    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;
        }

    }
}