#include <bits/stdc++.h>
const long long INF = LONG_LONG_MAX, MOD = 1e9 + 7;
using namespace std;
string Num;
long long dp[19][2][4], len;
long long noNumbers(long long idx, long long tight, long long cntNonZero) {
  if (cntNonZero > 3) return 0;
  if (idx == len) {
    if (cntNonZero <= 3)
      return 1;
    else
      return 0;
  }
  if (dp[idx][tight][cntNonZero] != -1) {
    ;
    return dp[idx][tight][cntNonZero];
  }
  long long lim;
  if (tight == 1)
    lim = Num[idx] - '0';
  else
    lim = 9;
  long long ans = 0, newTight;
  ;
  for (long long digit = 0; digit <= lim; ++digit) {
    newTight = (tight == 1 && digit == lim);
    if (digit == 0)
      ans = (ans + noNumbers(idx + 1, newTight, cntNonZero)) % MOD;
    else
      ans = (ans + noNumbers(idx + 1, newTight, cntNonZero + 1)) % MOD;
    ;
  };
  return dp[idx][tight][cntNonZero] = ans % MOD;
};
void solve() {
  long long n, i, j, nl, nr;
  cin >> nl >> nr;
  --nl;
  string l = to_string(nl), r = to_string(nr);
  memset(dp, -1LL, sizeof(dp));
  ;
  Num = l;
  len = Num.length();
  ;
  long long ansl = 0;
  ansl = noNumbers(0, 1, 0);
  ;
  Num = r;
  len = Num.length();
  long long ansr = 0;
  memset(dp, -1LL, sizeof(dp));
  ;
  ansr = noNumbers(0, 1, 0);
  ;
  ;
  ansr = (ansr - ansl + MOD) % MOD;
  cout << ansr;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  long long t;
  cin >> t;
  while (t--) {
    solve();
    cout << '\n';
  }
  return 0;
}

### Prompt

Please formulate a CPP solution to the following 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

### Response

```cpp
#include <bits/stdc++.h>
const long long INF = LONG_LONG_MAX, MOD = 1e9 + 7;
using namespace std;
string Num;
long long dp[19][2][4], len;
long long noNumbers(long long idx, long long tight, long long cntNonZero) {
  if (cntNonZero > 3) return 0;
  if (idx == len) {
    if (cntNonZero <= 3)
      return 1;
    else
      return 0;
  }
  if (dp[idx][tight][cntNonZero] != -1) {
    ;
    return dp[idx][tight][cntNonZero];
  }
  long long lim;
  if (tight == 1)
    lim = Num[idx] - '0';
  else
    lim = 9;
  long long ans = 0, newTight;
  ;
  for (long long digit = 0; digit <= lim; ++digit) {
    newTight = (tight == 1 && digit == lim);
    if (digit == 0)
      ans = (ans + noNumbers(idx + 1, newTight, cntNonZero)) % MOD;
    else
      ans = (ans + noNumbers(idx + 1, newTight, cntNonZero + 1)) % MOD;
    ;
  };
  return dp[idx][tight][cntNonZero] = ans % MOD;
};
void solve() {
  long long n, i, j, nl, nr;
  cin >> nl >> nr;
  --nl;
  string l = to_string(nl), r = to_string(nr);
  memset(dp, -1LL, sizeof(dp));
  ;
  Num = l;
  len = Num.length();
  ;
  long long ansl = 0;
  ansl = noNumbers(0, 1, 0);
  ;
  Num = r;
  len = Num.length();
  long long ansr = 0;
  memset(dp, -1LL, sizeof(dp));
  ;
  ansr = noNumbers(0, 1, 0);
  ;
  ;
  ansr = (ansr - ansl + MOD) % MOD;
  cout << ansr;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  long long t;
  cin >> t;
  while (t--) {
    solve();
    cout << '\n';
  }
  return 0;
}

```