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 abso(long long a) { return a > 0 ? a : (-a); }
long long cdiv(long long a, long long b) { return a / b + ((a % b) > 0); }
long long mul(long long a, long long b) {
  long long res = 0;
  while (b) {
    if (b & 1) res = (res + a) % 998244353;
    a = (a + a) % 998244353;
    b = b / 2;
  }
  return res;
}
long long bexp(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b = b / 2;
  }
  return res;
}
long long inv(long long a) { return bexp(a, 998244353 - 2); }
long long nCr(long long n, long long r) {
  long long fac[10];
  return mul(fac[n], mul(inv(fac[n - r]), inv(fac[r])));
}
struct compare {
  bool operator()(const long long& lhs, const long long& rhs) const {
    return lhs % 10 > rhs % 10;
  }
};
long long sz = 0;
long long x[20];
long long cache[20][2][5];
long long solve(long long idx, long long less, long long taken) {
  if (taken > 3) return 0;
  if (idx == sz) return 1;
  long long& ans = cache[idx][less][taken];
  if (ans != -1) return ans;
  ans = 0;
  if (!less) {
    for (long long dig = 0; dig <= x[idx]; dig++)
      ans += solve(idx + 1, less | dig < x[idx], taken + (dig > 0));
  } else {
    for (long long dig = 0; dig <= 9; dig++)
      ans += solve(idx + 1, 1, taken + (dig > 0));
  }
  return ans;
}
long long f(long long k) {
  memset(cache, -1, sizeof(cache));
  sz = 0;
  while (k > 0) {
    x[sz++] = k % 10;
    k /= 10;
  }
  reverse(x, x + sz);
  long long ans = solve(0, 0, 0);
  return ans;
}
void solve() {
  long long l, r;
  cin >> l >> r;
  cout << f(r) - f(l - 1) << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) solve();
}