#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const long long INF = (1LL << 61);
const int inf = (1 << 30);
const int nn = 1e6 + 5;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream second(s);
  string x;
  while (getline(second, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\t';
  err(++it, args...);
}
vector<int> v;
int N;
long long fun(int i, bool eq, int now) {
  if (i == N || now == 3) return 1;
  long long cnt = 0;
  if (eq) {
    if (v[i] > 0) {
      cnt += (v[i] - 1) * fun(i + 1, 0, now + 1);
      cnt += fun(i + 1, 1, now + 1);
      cnt += fun(i + 1, 0, now);
    } else {
      cnt += fun(i + 1, 1, now);
    }
  } else {
    cnt += 9 * fun(i + 1, 0, now + 1);
    cnt += fun(i + 1, 0, now);
  }
  return cnt;
}
void convert(long long n) {
  v.clear();
  while (n) {
    v.push_back(n % 10);
    n /= 10;
  }
  reverse(v.begin(), v.end());
  N = ((int)(v).size());
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    convert(b);
    long long ans = fun(0, 1, 0);
    convert(a - 1);
    ans -= fun(0, 1, 0);
    cout << ans << '\n';
  }
  return 0;
}

### Prompt

In CPP, your task is to solve 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;
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const long long INF = (1LL << 61);
const int inf = (1 << 30);
const int nn = 1e6 + 5;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream second(s);
  string x;
  while (getline(second, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\t';
  err(++it, args...);
}
vector<int> v;
int N;
long long fun(int i, bool eq, int now) {
  if (i == N || now == 3) return 1;
  long long cnt = 0;
  if (eq) {
    if (v[i] > 0) {
      cnt += (v[i] - 1) * fun(i + 1, 0, now + 1);
      cnt += fun(i + 1, 1, now + 1);
      cnt += fun(i + 1, 0, now);
    } else {
      cnt += fun(i + 1, 1, now);
    }
  } else {
    cnt += 9 * fun(i + 1, 0, now + 1);
    cnt += fun(i + 1, 0, now);
  }
  return cnt;
}
void convert(long long n) {
  v.clear();
  while (n) {
    v.push_back(n % 10);
    n /= 10;
  }
  reverse(v.begin(), v.end());
  N = ((int)(v).size());
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    convert(b);
    long long ans = fun(0, 1, 0);
    convert(a - 1);
    ans -= fun(0, 1, 0);
    cout << ans << '\n';
  }
  return 0;
}

```