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:
/**
 * Created by Alyssa Herbst on 9/19/2018 1:05 PM.
 */

import java.util.*;
import java.io.*;

import static java.lang.Math.*;

public class ClassyNumbers {
    static StringBuilder sb;
    static int N;
    static ArrayList<Long> nums;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        //Scanner sc = new Scanner(System.in);
        sb = new StringBuilder();
        N = sc.nextInt();
        nums = new ArrayList<>();
        addNums(0, 0, 0);
        nums.add((long)1e18);


        for (int i = 0; i < N; i++) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            int posA = Collections.binarySearch(nums, a);
            int posB = Collections.binarySearch(nums, b);
            if(posA < 0){
                posA = -posA - 1;
            }
            if(posB < 0) {
                posB = -posB - 2;
            }
            sb.append(posB - posA + 1).append('\n');
        }

        System.out.println(sb);
    }

    static void addNums(int pos, long curr, int C) {
        if(pos == 18) {
            nums.add(curr);
            return;
        }
        addNums(pos + 1, 10* curr, C);
        if(C >= 3) return;
        for (int i = 1; i < 10; i++) {
            addNums(pos + 1, 10* curr + i, C + 1);
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] readIntClassyNumbersrray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }

        long[] readLongClassyNumbersrray(int n) {
            long[] a = new long[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextLong();
            }
            return a;
        }
    }
}