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>
#pragma GCC optimize("O2")
using namespace std;
const long long INF64 = 1e18;
const long long INF32 = 1e9;
const long long BIG = (long long)(1e9 + 239);
const long long MOD = 998244353;
const long double PI = 2.0 * acos(0.0);
const long double EPS = static_cast<long double>(1e-10);
const long long day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const long long dx[4] = {0, 1, 0, -1};
const long long dy[4] = {1, 0, -1, 0};
mt19937 rnd(239);
void FILEIO() {
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
}
void input() {}
vector<long long> num;
long long a, b, k = 3;
long long DP[21][6][2];
long long call(long long pos, long long cnt, long long f) {
  if (cnt > k) {
    return 0;
  }
  if (pos == ((long long)(num).size())) {
    if (cnt <= k) {
      return 1;
    }
    return 0;
  }
  if (DP[pos][cnt][f] != -1) {
    return DP[pos][cnt][f];
  }
  long long res = 0;
  long long LMT;
  if (f == 0) {
    LMT = num[pos];
  } else {
    LMT = 9;
  }
  for (long long dgt = 0; dgt <= LMT; dgt++) {
    long long nf = f;
    long long ncnt = cnt;
    if (f == 0 && dgt < LMT) nf = 1;
    if (dgt != 0) ncnt++;
    if (ncnt <= k) {
      res += call(pos + 1, ncnt, nf);
    }
  }
  return DP[pos][cnt][f] = res;
}
long long solve(long long b) {
  num.clear();
  while (b > 0) {
    num.push_back(b % 10);
    b /= 10;
  }
  reverse(num.begin(), num.end());
  memset(DP, -1, sizeof(DP));
  long long res = call(0, 0, 0);
  return res;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  long long t;
  cin >> t;
  while (t--) {
    long long l, r;
    cin >> l >> r;
    cout << solve(r) - solve(l - 1) << endl;
    ;
  }
  return 0;
}