#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
const int maxn = 1000500;
inline int g() {
  int x;
  cin >> x;
  return x;
}
inline long long gl() {
  long long x;
  cin >> x;
  return x;
}
inline char gc() {
  char x;
  cin >> x;
  return x;
}
inline string gs() {
  string s;
  cin >> s;
  return s;
}
template <typename T>
inline vector<T> gv(int len) {
  vector<T> a(len);
  for (auto& it : a) cin >> it;
  return a;
}
inline vector<int> gv(int len) {
  vector<int> a(len);
  for (auto& it : a) cin >> it;
  return a;
}
inline vector<pair<int, int>> gv_andPairCnt(int len) {
  vector<pair<int, int>> a(len);
  int i = 1;
  for (auto& it : a) {
    it.second = i;
    i++;
    cin >> it.first;
  }
  return a;
}
double power_log(double power, double val) { return log(val) / log(power); }
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto it : v) os << it << ", ";
  os << "\n";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const deque<T>& v) {
  os << "deque:{";
  for (auto it : v) os << it << " ";
  os << "}\n";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  os << "set:{";
  for (auto it : v) os << it << " ";
  os << "}\n";
  return os;
}
template <typename T, typename H>
inline vector<pair<T, H>> gv_andBiPair(int len) {
  vector<pair<T, H>> a(len);
  for (auto& it : a) {
    cin >> it.first >> it.second;
  }
  return a;
}
template <typename T>
inline set<T> vector_to_set(const vector<T>& vec) {
  set<T> s;
  for (auto& it : vec) s.insert(it);
  return s;
}
const long long md = 1e9 + 7;
vector<long long> vi;
void rec(long long x, long long cnt, long long len) {
  if (len > 18) {
    return;
  }
  if (cnt > 3) {
    return;
  }
  if (len == 18) {
    vi.push_back(x);
  }
  for (long long i = 0; i <= 9; i++) {
    rec(x * 10 + i, cnt + (i != 0), len + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  rec(0, 0, 0);
  vi.push_back(1000000000000000000LL);
  sort(vi.begin(), vi.end());
  int n = g();
  auto cnt = [](long long x) {
    return upper_bound(vi.begin(), vi.end(), x) - vi.begin();
  };
  for (int i = 0; i < (n); ++i) {
    long long l = gl(), r = gl();
    cout << cnt(r) - cnt(l - 1) << "\n";
  }
}

### Prompt

Please create a solution in Cpp 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>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
const int maxn = 1000500;
inline int g() {
  int x;
  cin >> x;
  return x;
}
inline long long gl() {
  long long x;
  cin >> x;
  return x;
}
inline char gc() {
  char x;
  cin >> x;
  return x;
}
inline string gs() {
  string s;
  cin >> s;
  return s;
}
template <typename T>
inline vector<T> gv(int len) {
  vector<T> a(len);
  for (auto& it : a) cin >> it;
  return a;
}
inline vector<int> gv(int len) {
  vector<int> a(len);
  for (auto& it : a) cin >> it;
  return a;
}
inline vector<pair<int, int>> gv_andPairCnt(int len) {
  vector<pair<int, int>> a(len);
  int i = 1;
  for (auto& it : a) {
    it.second = i;
    i++;
    cin >> it.first;
  }
  return a;
}
double power_log(double power, double val) { return log(val) / log(power); }
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto it : v) os << it << ", ";
  os << "\n";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const deque<T>& v) {
  os << "deque:{";
  for (auto it : v) os << it << " ";
  os << "}\n";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  os << "set:{";
  for (auto it : v) os << it << " ";
  os << "}\n";
  return os;
}
template <typename T, typename H>
inline vector<pair<T, H>> gv_andBiPair(int len) {
  vector<pair<T, H>> a(len);
  for (auto& it : a) {
    cin >> it.first >> it.second;
  }
  return a;
}
template <typename T>
inline set<T> vector_to_set(const vector<T>& vec) {
  set<T> s;
  for (auto& it : vec) s.insert(it);
  return s;
}
const long long md = 1e9 + 7;
vector<long long> vi;
void rec(long long x, long long cnt, long long len) {
  if (len > 18) {
    return;
  }
  if (cnt > 3) {
    return;
  }
  if (len == 18) {
    vi.push_back(x);
  }
  for (long long i = 0; i <= 9; i++) {
    rec(x * 10 + i, cnt + (i != 0), len + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  rec(0, 0, 0);
  vi.push_back(1000000000000000000LL);
  sort(vi.begin(), vi.end());
  int n = g();
  auto cnt = [](long long x) {
    return upper_bound(vi.begin(), vi.end(), x) - vi.begin();
  };
  for (int i = 0; i < (n); ++i) {
    long long l = gl(), r = gl();
    cout << cnt(r) - cnt(l - 1) << "\n";
  }
}

```