#include <bits/stdc++.h>
using namespace std;
long long get(string s) {
  long long k = 1;
  long long ret = 0;
  for (int i = 0; i < 19; i++) {
    ret += k * (s[i] - '0');
    k *= 10;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s = "0000000000000000000";
  vector<long long> res;
  res.push_back(0);
  for (int i = 0; i < 19; i++) {
    for (char ch = '1'; ch <= '9'; ch++) {
      s[i] = ch;
      res.push_back(get(s));
      s[i] = '0';
    }
  }
  for (int i = 0; i < 19; i++) {
    for (int j = i + 1; j < 19; j++) {
      for (char ch1 = '1'; ch1 <= '9'; ch1++) {
        for (char ch2 = '1'; ch2 <= '9'; ch2++) {
          s[i] = ch1;
          s[j] = ch2;
          res.push_back(get(s));
          s[i] = '0';
          s[j] = '0';
        }
      }
    }
  }
  for (int i = 0; i < 19; i++) {
    for (int j = i + 1; j < 19; j++) {
      for (int k = j + 1; k < 19; k++) {
        for (char ch1 = '1'; ch1 <= '9'; ch1++) {
          for (char ch2 = '1'; ch2 <= '9'; ch2++) {
            for (char ch3 = '1'; ch3 <= '9'; ch3++) {
              s[i] = ch1;
              s[j] = ch2;
              s[k] = ch3;
              res.push_back(get(s));
              s[i] = '0';
              s[j] = '0';
              s[k] = '0';
            }
          }
        }
      }
    }
  }
  sort((res).begin(), (res).end());
  int t;
  cin >> t;
  while (t--) {
    long long l, r;
    cin >> l >> r;
    cout << lower_bound((res).begin(), (res).end(), r + 1) -
                lower_bound((res).begin(), (res).end(), l)
         << '\n';
  }
  return 0;
}

### Prompt

Develop a solution in cpp 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;
long long get(string s) {
  long long k = 1;
  long long ret = 0;
  for (int i = 0; i < 19; i++) {
    ret += k * (s[i] - '0');
    k *= 10;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s = "0000000000000000000";
  vector<long long> res;
  res.push_back(0);
  for (int i = 0; i < 19; i++) {
    for (char ch = '1'; ch <= '9'; ch++) {
      s[i] = ch;
      res.push_back(get(s));
      s[i] = '0';
    }
  }
  for (int i = 0; i < 19; i++) {
    for (int j = i + 1; j < 19; j++) {
      for (char ch1 = '1'; ch1 <= '9'; ch1++) {
        for (char ch2 = '1'; ch2 <= '9'; ch2++) {
          s[i] = ch1;
          s[j] = ch2;
          res.push_back(get(s));
          s[i] = '0';
          s[j] = '0';
        }
      }
    }
  }
  for (int i = 0; i < 19; i++) {
    for (int j = i + 1; j < 19; j++) {
      for (int k = j + 1; k < 19; k++) {
        for (char ch1 = '1'; ch1 <= '9'; ch1++) {
          for (char ch2 = '1'; ch2 <= '9'; ch2++) {
            for (char ch3 = '1'; ch3 <= '9'; ch3++) {
              s[i] = ch1;
              s[j] = ch2;
              s[k] = ch3;
              res.push_back(get(s));
              s[i] = '0';
              s[j] = '0';
              s[k] = '0';
            }
          }
        }
      }
    }
  }
  sort((res).begin(), (res).end());
  int t;
  cin >> t;
  while (t--) {
    long long l, r;
    cin >> l >> r;
    cout << lower_bound((res).begin(), (res).end(), r + 1) -
                lower_bound((res).begin(), (res).end(), l)
         << '\n';
  }
  return 0;
}

```