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;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
long long int dp[25][2][5], dp2[25][2][5];
void solve() {
  long long int L;
  string l, r;
  cin >> L >> r;
  --L;
  while (L > 0) {
    l += to_string(L % 10);
    L /= 10;
  }
  reverse(l.begin(), l.end());
  while (l.size() < 20) l = "0" + l;
  while (r.size() < 20) r = "0" + r;
  for (int i = 0; i < (25); ++i)
    for (int j = 0; j < (2); ++j)
      for (int k = 0; k < (5); ++k) {
        dp[i][j][k] = 0;
        dp2[i][j][k] = 0;
      }
  dp[0][1][0] = 1;
  dp2[0][1][0] = 1;
  for (int i = 0; i < (20); ++i) {
    int num = l[i] - '0';
    int num2 = r[i] - '0';
    for (int j = 0; j < (10); ++j) {
      for (int k = 0; k < (4); ++k) {
        int nk = k;
        if (j > 0) ++nk;
        dp[i + 1][0][nk] += dp[i][0][k];
        if (j == num) dp[i + 1][1][nk] += dp[i][1][k];
        if (j < num) dp[i + 1][0][nk] += dp[i][1][k];
        dp2[i + 1][0][nk] += dp2[i][0][k];
        if (j == num2) dp2[i + 1][1][nk] += dp2[i][1][k];
        if (j < num2) dp2[i + 1][0][nk] += dp2[i][1][k];
      }
    }
  }
  long long int ans = 0;
  for (int k = 0; k < (4); ++k)
    ans += dp2[20][0][k] + dp2[20][1][k] - dp[20][0][k] - dp[20][1][k];
  cout << ans << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int ti = 0; ti < (t); ++ti) solve();
  return 0;
}