#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll a, b, left, right;
ll dp[20][2][20];
vector<int> l, r;
ll Yeah(int pos, int flag, int cnt, vector<int> l) {
  if (pos == l.size()) {
    return (cnt <= 3);
  }
  if (dp[pos][flag][cnt] != -1) return dp[pos][flag][cnt];
  ll ans = 0, nflag, lim, c = 0;
  if (flag == 0)
    lim = 9;
  else if (flag == 1)
    lim = l[pos];
  for (int j = 0; j <= lim; j++) {
    if (j == l[pos])
      nflag = 1;
    else if (j < l[pos])
      nflag = 0;
    if (j != 0)
      c = 1;
    else if (j == 0)
      c = 0;
    ans += Yeah(pos + 1, flag & nflag, cnt + c, l);
  }
  return dp[pos][flag][cnt] = ans;
}
int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    cin >> a >> b;
    a--;
    while (a) {
      l.emplace_back(a % 10);
      a /= 10;
    }
    while (b) {
      r.emplace_back(b % 10);
      b /= 10;
    }
    reverse(l.begin(), l.end());
    reverse(r.begin(), r.end());
    memset(dp, -1, sizeof dp);
    ll ans1 = Yeah(0, 1, 0, r);
    memset(dp, -1, sizeof dp);
    ll ans2 = Yeah(0, 1, 0, l);
    cout << ans1 - ans2 << endl;
    memset(dp, -1, sizeof dp);
    r.clear(), l.clear();
  }
}

### 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>
using namespace std;
using ll = long long;
ll a, b, left, right;
ll dp[20][2][20];
vector<int> l, r;
ll Yeah(int pos, int flag, int cnt, vector<int> l) {
  if (pos == l.size()) {
    return (cnt <= 3);
  }
  if (dp[pos][flag][cnt] != -1) return dp[pos][flag][cnt];
  ll ans = 0, nflag, lim, c = 0;
  if (flag == 0)
    lim = 9;
  else if (flag == 1)
    lim = l[pos];
  for (int j = 0; j <= lim; j++) {
    if (j == l[pos])
      nflag = 1;
    else if (j < l[pos])
      nflag = 0;
    if (j != 0)
      c = 1;
    else if (j == 0)
      c = 0;
    ans += Yeah(pos + 1, flag & nflag, cnt + c, l);
  }
  return dp[pos][flag][cnt] = ans;
}
int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    cin >> a >> b;
    a--;
    while (a) {
      l.emplace_back(a % 10);
      a /= 10;
    }
    while (b) {
      r.emplace_back(b % 10);
      b /= 10;
    }
    reverse(l.begin(), l.end());
    reverse(r.begin(), r.end());
    memset(dp, -1, sizeof dp);
    ll ans1 = Yeah(0, 1, 0, r);
    memset(dp, -1, sizeof dp);
    ll ans2 = Yeah(0, 1, 0, l);
    cout << ans1 - ans2 << endl;
    memset(dp, -1, sizeof dp);
    r.clear(), l.clear();
  }
}

```