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>
#pragma GCC optimize("O3")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { return uniform_int_distribution<int>(0, x - 1)(rng); }
string s = "";
long long arr[20] = {0};
long long brr[1000005] = {0};
long long pw[20] = {0};
vector<long long> v;
vector<long long> g[1000005];
long long num(long long x) {
  long long ans = 0;
  while (x > 0) {
    x /= 10;
    ans++;
  }
  return ans;
}
long long fir(long long x) {
  long long ans = 0;
  while (1) {
    if (x < 10) return x;
    x /= 10;
  }
}
long long solve(long long x) {
  if (x < 1000) return x;
  long long ans = 999;
  long long nz = num(x);
  for (int i = 4; i < nz; i++) {
    ans += arr[i];
  }
  long long f = fir(x);
  ans += (f - 1) * ((81 * (nz - 1) * (nz - 2)) / 2 + 9 * (nz - 1) + 1);
  x -= f * pw[nz - 1];
  nz = num(x);
  f = fir(x);
  if (x < 100) {
    ans += x;
    return ans + 1;
  }
  ans += (f - 1) * (9 * (nz - 1) + 1);
  ans += 81 * (nz - 1) * (nz - 2) / 2 + 9 * (nz - 1) + 1;
  x -= f * pw[nz - 1];
  nz = num(x);
  f = fir(x);
  if (x < 10) {
    ans += x;
    return ans + 1;
  }
  ans += (f - 1);
  ans += 9 * (nz - 1) + 1;
  return ans + 1;
}
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n = 0, m = 0, k = 0, q = 0, ans = 0;
  long long x = 0, y = 0, t = 0, sum = 0, sz = 0;
  for (long long i = 4; i < 20; i++) {
    arr[i] = 9 * (81 * (i - 1) * (i - 2) / 2 + 9 * (i - 1) + 1);
  }
  pw[0] = 1;
  for (int i = 1; i <= 18; i++) {
    pw[i] = pw[i - 1] * 10;
  }
  cin >> t;
  while (t--) {
    cin >> x >> y;
    y = solve(y);
    x = solve(x - 1);
    cout << y - x << endl;
  }
  return 0;
}