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 MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI = acos(-1);
const int INF = 1e9;
const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
template <typename T>
T gcd(T a, T b) {
  return (b ? __gcd(a, b) : a);
}
template <typename T>
T lcm(T a, T b) {
  return (a * (b / gcd(a, b)));
}
template <typename T>
T add(T a, T b, T c = MOD) {
  T res = a + b;
  return (res >= c ? res - c : res);
}
template <typename T>
T mod_neg(T a, T b, T c = MOD) {
  T res;
  if (abs(a - b) < c)
    res = a - b;
  else
    res = (a - b) % c;
  return (res < 0 ? res + c : res);
}
template <typename T>
T mul(T a, T b, T c = MOD) {
  long long res = (long long)a * b;
  return (res >= c ? res % c : res);
}
inline long long mulmod(long long a, long long b, long long m = MOD) {
  long long q = (long long)(((long double)a * (long double)b) / (long double)m);
  long long r = a * b - q * m;
  if (r > m) r %= m;
  if (r < 0) r += m;
  return r;
}
template <typename T>
T expo(T e, T n) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = x * p;
    p = p * p;
    n >>= 1;
  }
  return x;
}
template <typename T>
T power(T e, T n, T m = MOD) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = mul(x, p, m);
    p = mul(p, p, m);
    n >>= 1;
  }
  return x;
}
template <typename T>
T extended_euclid(T a, T b, T &x, T &y) {
  T xx = 0, yy = 1;
  y = 0;
  x = 1;
  while (b) {
    T q = a / b, t = b;
    b = a % b;
    a = t;
    t = xx;
    xx = x - q * xx;
    x = t;
    t = yy;
    yy = y - q * yy;
    y = t;
  }
  return a;
}
template <typename T>
T mod_inverse(T a, T n = MOD) {
  T x, y, z = 0;
  T d = extended_euclid(a, n, x, y);
  return (d > 1 ? -1 : mod_neg(x, z, n));
}
vector<long long> res;
void brute(int pos, int cnt, long long cur) {
  if (pos == 18) {
    res.push_back(cur);
    return;
  }
  brute(pos + 1, cnt, cur * 10);
  if (cnt < 3)
    for (int i = 1; i <= 9; ++i) brute(pos + 1, cnt + 1, cur * 10 + i);
}
void solve() {
  long long k = 0, n = 0, x = 0, m = 0, curr = 0, num = 0, n1 = 0, n2 = 0,
            n3 = 0, n4 = 0, i = 0, j = 0;
  long long root = 0, sum = 0, diff = 0, q = 0, choice = 0, d = 0, len = 0,
            beg = 0, end = 0, pos = 0, cnt = 0;
  long long lo = 0, hi = 0, mid = 0, ans = 0;
  bool flag = false;
  string s1, s2, s3, str;
  char ch, ch1, ch2, ch3, *ptr;
  double dub = 0;
  cin >> lo >> hi;
  ans = int(upper_bound(res.begin(), res.end(), hi) -
            lower_bound(res.begin(), res.end(), lo));
  cout << ans << "\n";
}
int main() {
  brute(0, 0, 0);
  res.push_back(1000000000000000000);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}