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

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
template <typename T>
void print(T v, bool show_index = false) {
  int w = 2;
  if (show_index) {
    for (int i = 0; i < v.size(); i++) cout << setw(w) << i << " ";
  }
  cout << endl;
  for (auto i = v.begin(); i != v.end(); i++) cout << setw(w) << *i << " ";
  cout << endl;
}
template <typename T>
void print_vv(T v) {
  int w = 3;
  cout << setw(w) << " ";
  for (int j = 0; j < v[0].size(); j++) cout << setw(w) << j << " ";
  cout << endl;
  for (auto i = 0; i < v.size(); i++) {
    cout << i << " {";
    for (auto j = 0; j != v[i].size(); j++) {
      cout << setw(w) << v[i][j] << ",";
    }
    cout << "}," << endl;
  }
  cout << endl;
}
const int MAXN = 20;
long long C[MAXN + 1][MAXN + 1];
void precalc() {
  C[0][0] = 1;
  for (int i = 1; i <= MAXN; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j <= i / 2; j++)
      C[i][j] = C[i][i - j] = C[i - 1][j - 1] + C[i - 1][j];
  }
}
long long Comb(int n, int k) {
  if (k < 0 || k > n) return 0;
  return C[n][k];
}
long long get(int n, int k) {
  long long ans = 0;
  for (int i = 0; i < int(k + 1); i++) ans += Comb(n, i) * pow(9, i);
  return ans;
}
long long classy(long long x) {
  string s = to_string(x);
  long long ans = 0;
  int cur = 3;
  int n = s.size();
  for (int i = 0; i < int(n); i++) {
    if (s[i] == '0') continue;
    int x = n - i;
    ans += get(x - 1, cur);
    --cur;
    if (cur == -1) break;
    ans += get(x - 1, cur) * (s[i] - '1');
  }
  return ans;
}
int main() {
  precalc();
  int t;
  long long x, y;
  cin >> t;
  while (t--) {
    cin >> x >> y;
    long long ans = classy(y + 1) - classy(x);
    cout << ans << endl;
  }
  return 0;
}