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;
long long memo[20][20][2];
long long DP(long long digit_ke, long long cnt0, long long flag, string R) {
  if (digit_ke >= R.length()) {
    if (cnt0 <= 3)
      return 1;
    else
      return 0;
  }
  if (memo[digit_ke][cnt0][flag] != -1) return memo[digit_ke][cnt0][flag];
  long long ans = 0;
  if (flag == 1) {
    if (R[digit_ke] == '0')
      ans += DP(digit_ke + 1, cnt0, 1, R);
    else
      ans += DP(digit_ke + 1, cnt0 + 1, 1, R);
    for (long long dig = 0; dig < (long long)(R[digit_ke] - '0'); dig++) {
      if (dig == 0)
        ans += DP(digit_ke + 1, cnt0, 0, R);
      else
        ans += DP(digit_ke + 1, cnt0 + 1, 0, R);
    }
  } else {
    for (long long dig = 0; dig <= 9; dig++) {
      if (dig == 0)
        ans += DP(digit_ke + 1, cnt0, 0, R);
      else
        ans += DP(digit_ke + 1, cnt0 + 1, 0, R);
    }
  }
  return memo[digit_ke][cnt0][flag] = ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    memset(memo, -1, sizeof(memo));
    string L, R;
    cin >> L >> R;
    long long res1 = DP(0, 0, 1, R);
    memset(memo, -1, sizeof(memo));
    long long res2 = DP(0, 0, 1, L);
    long long berapa = 0;
    for (long long i = 0; i < L.length(); i++) {
      if (L[i] != '0') berapa++;
    }
    if (berapa <= 3) res2--;
    cout << res1 - res2 << endl;
  }
  return 0;
}