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;
const int N = 1000050;
const long long Mod = 1000000007;
const int inf = 0x3f3f3f3f;
long long C[20];
long long getPow(int x) {
  long long ret = 1;
  for (int i = 1; i < ((x) + 1); i++) {
    ret *= 9;
  }
  return ret;
}
long long getC(int n, int m) {
  if (m < 0 || m > n) return 0;
  return C[n] / (C[m] * C[n - m]);
}
long long getRet(long long num) {
  string dig = to_string(num);
  int len = (int)dig.length() - 1;
  long long ret = 0;
  int k = 3;
  for (int i = 0; i < ((len) + 1); i++) {
    if (dig[i] == '0') {
      continue;
    }
    for (int j = 0; j < ((k) + 1); j++) {
      ret += getC(len - i, j) * getPow(j);
    }
    if (k == 0) {
      break;
    }
    k--;
    for (int j = 0; j < ((k) + 1); j++) {
      ret += (dig[i] - '1') * getC(len - i, j) * getPow(j);
    }
  }
  return ret;
}
int main(int argc, const char* argv[]) {
  int l;
  scanf("%d", &l);
  C[0] = 1;
  for (int i = 1; i < ((20) + 1); i++) C[i] = i * C[i - 1];
  for (int i = 1; i < ((l) + 1); i++) {
    long long a, b;
    cin >> a >> b;
    cout << getRet(b + 1) - getRet(a) << endl;
  }
  return 0;
}