#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[30], D;
long long Dp[30][50][3];
long long dp(int i, int cnt, int f) {
  if (i == D) return 1;
  long long &ret = Dp[i][cnt][f];
  if (ret != -1) return ret;
  int mx = f ? 9 : a[i];
  long long d = 0;
  if (!cnt) mx = 0;
  for (int j = 0; j <= mx; j++) {
    d += dp(i + 1, cnt - (j != 0), f || j < a[i]);
  }
  return ret = d;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    long long x, y, k;
    cin >> x >> y;
    k = y;
    D = 0;
    while (k) {
      a[D] = k % 10;
      k /= 10;
      D++;
    }
    reverse(a, a + D);
    memset(Dp, -1, sizeof Dp);
    long long Ans = dp(0, 3, 0);
    k = x - 1;
    D = 0;
    while (k) {
      a[D] = k % 10;
      k /= 10;
      D++;
    }
    reverse(a, a + D);
    memset(Dp, -1, sizeof Dp);
    Ans -= dp(0, 3, 0);
    cout << Ans << "\n";
  }
}

### Prompt

Your challenge is to write a cpp solution 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>
using namespace std;
const int N = 1e5 + 10;
int a[30], D;
long long Dp[30][50][3];
long long dp(int i, int cnt, int f) {
  if (i == D) return 1;
  long long &ret = Dp[i][cnt][f];
  if (ret != -1) return ret;
  int mx = f ? 9 : a[i];
  long long d = 0;
  if (!cnt) mx = 0;
  for (int j = 0; j <= mx; j++) {
    d += dp(i + 1, cnt - (j != 0), f || j < a[i]);
  }
  return ret = d;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    long long x, y, k;
    cin >> x >> y;
    k = y;
    D = 0;
    while (k) {
      a[D] = k % 10;
      k /= 10;
      D++;
    }
    reverse(a, a + D);
    memset(Dp, -1, sizeof Dp);
    long long Ans = dp(0, 3, 0);
    k = x - 1;
    D = 0;
    while (k) {
      a[D] = k % 10;
      k /= 10;
      D++;
    }
    reverse(a, a + D);
    memset(Dp, -1, sizeof Dp);
    Ans -= dp(0, 3, 0);
    cout << Ans << "\n";
  }
}

```