#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t, l, r, x, q, n, m, o = 0;
  cin >> t;
  set<long long> c;
  set<long long>::iterator it1, itu;
  map<long long, long long> s;
  for (long long j = 1; j < 1000; j++) {
    c.insert(j);
  }
  for (long long dl = 4; dl < 20; dl++) {
    for (long long a = dl - 1; a >= 2; a--) {
      for (long long b = dl; b >= a + 1; b--) {
        for (long long z1 = 1; z1 < 10; z1++) {
          for (long long z2 = 0; z2 < 10; z2++) {
            for (long long z3 = 0; z3 < 10; z3++) {
              x = z1 * pow(10, dl - 1) + z2 * pow(10, dl - a) +
                  z3 * pow(10, dl - b);
              q = c.size();
              c.insert(x);
            }
          }
        }
      }
    }
  }
  x = 2000000000000000000;
  c.insert(x);
  set<long long>::iterator it;
  for (it = c.begin(); it != c.end(); it++) {
    q = *it;
    s[q] = o;
    o = o + 1;
  }
  for (long long a = 0; a < t; a++) {
    cin >> l >> r;
    it1 = c.lower_bound(l);
    n = *it1;
    n = s[n];
    it1 = c.lower_bound(r);
    m = *it1;
    if (r != m) {
      m = s[m] - 1;
    } else {
      m = s[m];
    }
    if (m - n < 0) {
      cout << 0 << " ";
    } else {
      cout << m - n + 1 << " ";
    }
  }
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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 namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t, l, r, x, q, n, m, o = 0;
  cin >> t;
  set<long long> c;
  set<long long>::iterator it1, itu;
  map<long long, long long> s;
  for (long long j = 1; j < 1000; j++) {
    c.insert(j);
  }
  for (long long dl = 4; dl < 20; dl++) {
    for (long long a = dl - 1; a >= 2; a--) {
      for (long long b = dl; b >= a + 1; b--) {
        for (long long z1 = 1; z1 < 10; z1++) {
          for (long long z2 = 0; z2 < 10; z2++) {
            for (long long z3 = 0; z3 < 10; z3++) {
              x = z1 * pow(10, dl - 1) + z2 * pow(10, dl - a) +
                  z3 * pow(10, dl - b);
              q = c.size();
              c.insert(x);
            }
          }
        }
      }
    }
  }
  x = 2000000000000000000;
  c.insert(x);
  set<long long>::iterator it;
  for (it = c.begin(); it != c.end(); it++) {
    q = *it;
    s[q] = o;
    o = o + 1;
  }
  for (long long a = 0; a < t; a++) {
    cin >> l >> r;
    it1 = c.lower_bound(l);
    n = *it1;
    n = s[n];
    it1 = c.lower_bound(r);
    m = *it1;
    if (r != m) {
      m = s[m] - 1;
    } else {
      m = s[m];
    }
    if (m - n < 0) {
      cout << 0 << " ";
    } else {
      cout << m - n + 1 << " ";
    }
  }
}

```