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.util.*;
import java.io.*;
import java.math.*;

public class Main {

	static class FastScanner {
		BufferedReader s;
		StringTokenizer st;

		public FastScanner(InputStream InputStream) {
			st = new StringTokenizer("");
			s = new BufferedReader(new InputStreamReader(InputStream));
		}

		public FastScanner(File f) throws FileNotFoundException {
			st = new StringTokenizer("");
			s = new BufferedReader(new FileReader(f));
		}

		public int nextInt() throws IOException {
			if (st.hasMoreTokens())
				return Integer.parseInt(st.nextToken());
			else {
				st = new StringTokenizer(s.readLine());
				return nextInt();
			}
		}

		public BigInteger big() throws IOException {
			if (st.hasMoreTokens())
				return new BigInteger(st.nextToken());
			else {
				st = new StringTokenizer(s.readLine());
				return big();
			}
		}

		public double nextDouble() throws IOException {
			if (st.hasMoreTokens())
				return Double.parseDouble(st.nextToken());
			else {
				st = new StringTokenizer(s.readLine());
				return nextDouble();
			}
		}

		public long nextLong() throws IOException {
			if (st.hasMoreTokens())
				return Long.parseLong(st.nextToken());
			else {
				st = new StringTokenizer(s.readLine());
				return nextLong();
			}
		}

		public String next() throws IOException {
			if (st.hasMoreTokens())
				return st.nextToken();
			else {
				st = new StringTokenizer(s.readLine());
				return next();
			}

		}

		public String nextLine() throws IOException {
			return s.readLine();
		}

		public void close() throws IOException {
			s.close();
		}

	}

	public static void main(String[] args) throws java.lang.Exception {
		FastScanner in = new FastScanner(System.in);
		int test = in.nextInt();
		brute(0, 0, 0);
	    res.add((long)1e18 );
		StringBuilder sb = new StringBuilder("");
		while(test-- > 0) {
			long n1 = in.nextLong(), n2 = in.nextLong();
			sb.append(bs(n2) - bs(n1 - 1) + "\n");
		}
		System.out.print(sb);
	}

	private static int bs(long n2) {
		int start = 0, end = res.size() - 1;
		while(start <= end) {
			int mid = start + (end - start)/2;
			Long val = res.get(mid);
			if(val == n2 || (res.get(mid + 1) > n2 && val < n2 )) {
				return mid;
			}
			else if(end - start == 1)
				return mid + 1;
			else if(val < n2) {
				start = mid;
			}
			else {
				end = mid - 1;
			}
		}
		return -1;
	}

	static ArrayList<Long> res = new ArrayList();

	private static void brute(int pos, int cnt, long cur){
	    if (pos == 18){
	        res.add(cur);
	        return;
	    }
	    
	    brute(pos + 1, cnt, cur * 10);
	    
	    if (cnt < 3)
	        for (int i = 1; i <= 9; ++i)
	            brute(pos + 1, cnt + 1, cur * 10 + i);
	}
}