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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 40;
long long int dp[N][10][10];
long long int x;
long long int num = 0;
vector<int> nums;
int sz = -1;
long long int f(int idx, int left, int less) {
  if (left > 3) return 0;
  if (idx == sz) return 1;
  long long int &ret = dp[idx][left][less];
  if (ret > -1) return ret;
  ret = 0;
  if (less) {
    for (int i = 0; i < 10; i++) {
      ret = ret + f(idx + 1, left + (i > 0), 1);
    }
  } else {
    for (int i = 0; i <= nums[idx]; i++) {
      ret = (ret + f(idx + 1, left + (i > 0), less | (i < nums[idx])));
    }
  }
  return ret;
}
long long int solve(long long int x) {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        dp[i][j][k] = -1;
      }
    }
  }
  nums.clear();
  long long int temp = x;
  while (temp > 0) {
    nums.push_back(temp % 10);
    temp /= 10;
  }
  sz = nums.size();
  reverse(nums.begin(), nums.end());
  long long int ans = f(0, 0, 0);
  return ans;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int l, r;
    cin >> l >> r;
    cout << solve(r) - solve(l - 1) << endl;
  }
}