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

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);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {

        long dp[][][] = new long[20][5][2];
        long d[] = new long[20];
        long f(int u, int dg, boolean flag){
            if (dg > 3) {
                return 0;
            }
            if (u == 0) {
                return 1;
            }
            if (dp[u][dg][flag? 1: 0] != -1) {
                return dp[u][dg][flag? 1: 0];
            }
            long lim = flag ? d[u] : 9;
            long ans = 0;
            for (int i = 0; i <= lim; i++) {
                ans += f(u - 1, dg + (i != 0? 1: 0), flag && (d[u] == i));
            }
            return dp[u][dg][flag? 1: 0] = ans;
        }

        long query(long n) {
            for (int i = 0; i < dp.length; ++i) {
                for (int j = 0; j < dp[0].length; ++j) {
                    for (int k = 0; k < dp[0][0].length; ++k) {
                        dp[i][j][k] = -1;
                    }
                }
            }
            int t = 0;
            while (n != 0) {
                ++t;
                d[t] = n % 10;
                n /= 10;
            }
            return f(t, 0, true);
        }

        void solve(int testNumber, InputReader in, PrintWriter out) {
            for (int T = in.nextInt(); T-- > 0;){
                long l = in.nextLong(), r = in.nextLong();
                out.println(query(r) - query(l - 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());
        }

    }
}