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

public class Solution {
    private static long[][][] dp;
    private static long get_classy(char[] arr) {
        int n = arr.length;
        dp = new long[n][4][10];
        dp[0][0][0] = 1;
        for (int i=1; i<10; i++) dp[0][1][i] = 1;
        for (int i=1; i<n; i++) {
            dp[i][0][0] = 1;
            for (int j=1; j<4; j++) {
                for (int k=0; k<10; k++) {
                    for (int k_prev=0; k_prev<10; k_prev++) {
                        if (k==0) dp[i][j][k]+=dp[i-1][j][k_prev];
                        else dp[i][j][k]+=dp[i-1][j-1][k_prev];
                    }
                }
            }
        }
        long res = 0;
        int notzeroes = 0;
        boolean breaking = false;
        for (int i=n-1; i>-1; i--) {
            int x = Character.getNumericValue(arr[n-i-1]);
            for (int j=0; j<4-notzeroes; j++) {
                for (int k=0; k<x; k++) {
                    res+=dp[i][j][k];
                }
            }
            if (x>0) notzeroes++;
            if (notzeroes>3) {
                breaking = true; break;
            }
        }
        if (!breaking) res++;
        return res;
    }
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(reader.readLine());
        StringBuilder ans = new StringBuilder();
        while (t-->0) {
            StringTokenizer sToken = new StringTokenizer(reader.readLine());
            long l_given = Long.parseLong(sToken.nextToken()) - 1;
            char[] l = Long.toString(l_given).toCharArray();
            char[] r = sToken.nextToken().toCharArray();
            ans.append(get_classy(r)-get_classy(l)).append("\n");
        }
        System.out.println(ans);
    }
}