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;
long long n, m, mod = 1e9 + 7, a, b;
long long w[200003];
vector<long long> v;
long long poww(long long x, long long y) {
  if (x == 0) return 0;
  if (x == 1) return 1;
  if (y == 0) return 1;
  if (y == 1) return x;
  long long d = poww(x, y / 2);
  d *= d;
  if (y % 2) return (x * d);
  return d;
}
bool bl(long long x, long long y) { return x > y; }
void f() {
  for (int i = 1; i <= 18; i++) {
    long long d1 = 0;
    for (int ii = 1; ii < 10; ii++) {
      d1 = ii * poww(10, i - 1);
      v.push_back(d1);
      for (int j = 1; j < i; j++) {
        for (int jj = 1; jj < 10; jj++) {
          long long d2 = d1;
          d2 += jj * poww(10, j - 1);
          v.push_back(d2);
          for (int k = 1; k < j; k++) {
            for (int kk = 1; kk < 10; kk++) {
              long long d3 = d2;
              d3 += kk * poww(10, k - 1);
              v.push_back(d3);
            }
          }
        }
      }
    }
  }
}
long long bs(long long l, long long r, long long x) {
  long long an;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (v[mid] <= x) {
      an = mid;
      l = mid + 1;
      continue;
    }
    r = mid - 1;
  }
  return an;
}
int main() {
  f();
  sort(v.begin(), v.end());
  v.push_back(1000000000000000000);
  v.push_back(1000000000000000001);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    long long d1 = lower_bound(v.begin(), v.end(), a) - v.begin();
    long long d2 = bs(0, v.size(), b);
    printf("%lld\n", d2 - d1 + 1);
  }
  return 0;
}