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 static java.lang.Double.parseDouble;
import static java.lang.Integer.MAX_VALUE;
import static java.lang.Integer.max;
import static java.lang.Long.max;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.abs;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.*;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;

public class A {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    static char[] s;
    static int dp[][][] = new int[20][5][2];
    static int fun(int i,int d,boolean isL) {
        if(i == s.length) return 1;
        if (dp[i][d][isL?1:0] != -1) return dp[i][d][isL?1:0];
        int ans = 0;
        for(int j = 0; j <= 9; j++)
            if(j <= s[i] - '0' || isL) {
                if(j == 0) ans += fun(i+1, d, isL || j < s[i] - '0');
                else if(d < 3) ans += fun(i+1, d + 1, isL || j < s[i] - '0');
            }
        return dp[i][d][isL?1:0] = ans;
    }

    static void solve() throws Exception {
        int t = nextInt();
        for(int tt = 0; tt < t; tt++) {
            long a = nextLong(), b = nextLong();
            s = String.valueOf(b).toCharArray();
            for (int i = 0; i < 20; i++) for (int j = 0; j < 5; j++) Arrays.fill(dp[i][j], -1);
            int ans = fun(0, 0, false);
            s = String.valueOf(a-1).toCharArray();
            for (int i = 0; i < 20; i++) for (int j = 0; j < 5; j++) Arrays.fill(dp[i][j], -1);
            ans -= fun(0, 0, false);
            out.println(ans);
        }
    }

    public static int lower_bound(int[] a, long v) {
        int low = -1, high = a.length;
        while(high-low > 1){
            int h = high+low>>>1;
            if(a[h] >= v){
                high = h;
            }else{
                low = h;
            }
        }
        return high;
    }


    private static long gcd(long a, long b) {
        while (b > 0) {
            long temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }

    private static long lcm(long a, long b) {
        return a * (b / gcd(a, b));
    }

    static int nextInt() throws IOException {
        return parseInt(next());
    }

    static long nextLong() throws IOException {
        return parseLong(next());
    }

    static double nextDouble() throws IOException {
        return parseDouble(next());
    }

    static String next() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    public static void main(String[] args) throws Exception {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            //long lStartTime = System.currentTimeMillis();
            solve();
            //long lEndTime = System.currentTimeMillis();
            //out.println("Elapsed time in seconds: " + (double)(lEndTime - lStartTime) / 1000.0);
            in.close();
            out.close();
        } catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}