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 MOD = 1000000007;
const int N = 300005;
const double PI = 4 * atan(1);
const long long MAX = 9223372036854775807;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
bool issquare(long long w) { return trunc(sqrt(w)) * trunc(sqrt(w)) == w; }
bool isprime(long long u) {
  for (long long i = 2; i <= (int)sqrt(u); i++) {
    if (u % i == 0) return 0;
  }
  return 1;
}
long long mod(long long to_mod, long long MOD) {
  to_mod %= MOD;
  while (to_mod < 0) to_mod += MOD;
  return to_mod % MOD;
}
long long moduloMultiplication(long long a, long long b, long long mod) {
  long long res = 0;
  a %= mod;
  while (b) {
    if (b & 1) res = (res + a) % mod;
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}
long long power(long long x, long long y) {
  long long res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long n, m, x, y, res, t, k, q, z, w, l, r, ans;
vector<long long> v;
long long b[20];
long long getmin(long long u) {
  long long l = 0;
  long long r = k - 1;
  while (l != r - 1) {
    long long mid = (l + r) / 2;
    if (v[mid] > u) {
      r = mid;
    } else {
      l = mid;
    }
  }
  if (v[l] >= u) return l;
  return r;
}
long long getmax(long long u) {
  long long l = 0;
  long long r = k - 1;
  while (l != r - 1) {
    long long mid = (l + r) / 2;
    if (v[mid] > u) {
      r = mid;
    } else {
      l = mid;
    }
  }
  if (v[r] <= u) return r;
  return l;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  b[0] = 1;
  for (int i = 1; i <= 18; i++) {
    b[i] = 10 * b[i - 1];
  }
  for (int i = 0; i < 18; i++) {
    for (int j = 1; j <= 9; j++) {
      x = b[i] * j;
      for (int k = i + 1; k < 18; k++) {
        for (int u = 1; u <= 9; u++) {
          y = x + b[k] * u;
          for (int o = k + 1; o < 18; o++) {
            for (int r = 1; r <= 9; r++) {
              z = y + b[o] * r;
              if (z < 1e18 && z >= 1) v.push_back(z);
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < 18; i++) {
    for (int j = 1; j <= 9; j++) {
      x = b[i] * j;
      for (int k = i + 1; k < 18; k++) {
        for (int u = 1; u <= 9; u++) {
          y = x + b[k] * u;
          if (y < 1e18 && y >= 1) {
            v.push_back(y);
          }
        }
      }
    }
  }
  for (int i = 0; i < 18; i++) {
    for (int j = 1; j <= 9; j++) {
      x = b[i] * j;
      if (x < 1e18 && x >= 1) v.push_back(x);
    }
  }
  v.push_back(1000000000000000000);
  k = v.size();
  sort(v.begin(), v.end());
  while (n--) {
    cin >> x >> y;
    x = getmin(x);
    y = getmax(y);
    cout << max(y - x + 1, 0ll) << endl;
  }
  return 0;
}