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.*;


/**
 * @authod Rashedul Hasan Rijul
 */
public class Solution {

    static char[] str;
    static long[][][] dp;
    static boolean[][][] vis;

    public static void main(String args[]) throws FileNotFoundException {

        // for testing in local
        //FastReader fastReader = FastReader.getFileReader("in.txt");

        FastReader fastReader = FastReader.getDefaultReader();

        int test = fastReader.nextInt();

        while ((test--) !=0 ){

            long L  = fastReader.nextLong();
            long R  = fastReader.nextLong();

            System.out.println(getAns(R) - getAns(L-1));
        }
    }

    private static long getAns(long num) {

        if(num==0) return 1;

        str = String.valueOf(num).toCharArray();

        dp = new long[30][3][5];
        vis = new boolean[30][3][5];

        for(int i=0;i<30;i++){
            for(int j=0;j<3;j++){
                for(int k=0;k<5;k++){
                    vis[i][j][k]=false;
                }
            }
        }

        //System.out.println(num + " ans : " + cal(0, false, 3));
        return cal(0, false, 3);
    }

    private static long cal(int ind, boolean small, int remNonZero){

        if(remNonZero<0) return 0;
        if(ind == str.length) return 1;

        int s = (small == true) ? 1 : 0;

        if(vis[ind][s][remNonZero]==true) return dp[ind][s][remNonZero];
        vis[ind][s][remNonZero]=true;

        boolean newSmall = true;

        long ret=0;

        for(int i=0;i<10;i++){
            if(small == false && str[ind]-'0'<i){
                continue;
            }

            if(small == false && str[ind]-'0' == i){
                newSmall = false;
            } else {
                newSmall = true;
            }
            if(i!=0) {
                ret += cal(ind + 1, newSmall, remNonZero-1);
            } else {
                ret += cal(ind+1, newSmall, remNonZero);
            }
        }

        return dp[ind][s][remNonZero]=ret;
    }


    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        public static FastReader getFileReader(String fileName) throws FileNotFoundException {
            return new FastReader(new InputStreamReader(new FileInputStream(new File("in.txt"))));
        }

        public static FastReader getDefaultReader() throws FileNotFoundException {
            return new FastReader();
        }

        public FastReader(InputStreamReader inputStreamReader) {
            br = new BufferedReader(inputStreamReader);
        }

        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 nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}