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;
using lint = long long int;
template <class T = int>
using V = vector<T>;
template <class T = int>
using VV = V<V<T>>;
template <class T>
void assign(V<T>& v, int n, const T& a = T()) {
  v.assign(n, a);
}
template <class T, class... U>
void assign(V<T>& v, int n, const U&... u) {
  v.resize(n);
  for (auto&& i : v) assign(i, u...);
}
int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  auto calc = [](string x, int in) {
    int n = x.size();
    VV<V<lint>> dp;
    assign(dp, n + 1, 2, 5);
    dp[0][1][0] = 1;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < 5; j++)
        for (int d = 0; d < 10; d++) {
          dp[i + 1][0][min(j + !!d, 4)] += dp[i][0][j];
          if (d > x[i] - '0') continue;
          dp[i + 1][d == x[i] - '0'][min(j + !!d, 4)] += dp[i][1][j];
        }
    lint res = 0;
    for (int f = 0; f <= in; f++)
      for (int j = 0; j < 4; j++) res += dp[n][f][j];
    return res;
  };
  int t;
  cin >> t;
  for (int it = 0; it < t; it++) {
    string l, r;
    cin >> l >> r;
    cout << calc(r, 1) - calc(l, 0) << '\n';
  }
}