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.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Solution {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int t = Integer.parseInt(br.readLine());
        ArrayList<Long> list = new ArrayList<>();
        for (int i = 1; i <= 9; i++)
            generate(list, 2, i, 1000000000000000000L);
        Collections.sort(list);
        while (t-- > 0) {
            String str = br.readLine();
            StringTokenizer st = new StringTokenizer(str, " ");
            long l = Long.parseLong(st.nextToken());
            long r = Long.parseLong(st.nextToken());
            int right = binarySearch(list, r);
            int left = binarySearch(list, l - 1);
            pw.println(right - left);
        }
        pw.close();
    }

    private static void generate(ArrayList<Long> store, int cnt, long number, long max) {
        if (number <= 0 || number > max) {
            return;
        }
        store.add(number);
        if (cnt != 0) {
            for (int i = 1; i < 10; i++) {
                generate(store, cnt - 1, number * 10 + i, max);
            }
        }
        generate(store, cnt, number * 10, max);
    }

    private static int binarySearch(ArrayList<Long> list, long n) {
        int low = 0, high = list.size() - 1;
        while (low <= high) {
            int mid = (low + high) / 2;
            if (list.get(mid) == n) {
                return mid + 1;
            } else if (list.get(mid) < n) {
                low = mid + 1;
            } else {
                high = mid - 1;
            }
        }
        return low;
    }
}