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;
int nTest;
long long Count[20][4];
long long Base[20];
int lis[20];
int nLis;
long long Cal(long long value) {
  if (!value) return 0;
  long long ans = 0;
  for (int i = 1; Base[i] - 1 < value; ++i) {
    ans += (Count[i - 1][0] + Count[i - 1][1] + Count[i - 1][2]) * 9ll;
  }
  long long foo = value;
  while (foo) {
    lis[++nLis] = foo % 10;
    foo /= 10;
  }
  int cur = 0;
  reverse(lis + 1, lis + nLis + 1);
  for (int i = 1; i <= nLis; ++i) {
    int bar = max(0, lis[i] - 1);
    for (int j = 0; j < 3 - cur; ++j) ans += 1ll * bar * Count[nLis - i][j];
    if (lis[i] && i != 1) {
      for (int j = 0; j <= 3 - cur; ++j) ans += Count[nLis - i][j];
    }
    if (lis[i]) cur++;
    if (cur == 3 || i == nLis) {
      ans++;
      break;
    }
  }
  nLis = 0;
  return ans;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin >> nTest;
  Count[0][0] = 1;
  Count[1][1] = 9;
  Count[1][0] = 1;
  Base[0] = 1;
  for (int i = 1; i <= 18; ++i) Base[i] = Base[i - 1] * 10;
  for (int i = 2; i <= 18; ++i) {
    for (int num = 0; num <= 2; ++num) {
      Count[i][num] = Count[i - 1][num];
      if (num) Count[i][num] += 9ll * Count[i - 1][num - 1];
    }
  }
  while (nTest--) {
    long long l, r;
    cin >> l >> r;
    long long ans = 0;
    if (r == (long long)1e18) ans++, r--;
    ans += Cal(r) - Cal(l - 1);
    cout << ans << endl;
  }
  return 0;
}