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;
vector<long long> v;
long long sti(string x) {
  long long i, res = 0;
  for (i = 0; i < x.size(); i++) res = res * 10 + x[i] - 48;
  return res;
}
void kt(long long x) {
  long long i;
  string s;
  for (i = 0; i < x; i++) s.push_back('0');
  for (int i1 = 1; i1 <= 9; i1++) {
    s[0] = char(i1 + 48);
    for (int j = 1; j < x; j++) {
      for (int j1 = 0; j1 <= 9; j1++) {
        s[j] = char(j1 + 48);
        for (int t = j + 1; t < x; t++) {
          for (int t1 = 0; t1 <= 9; t1++) {
            s[t] = char(t1 + 48);
            v.push_back(sti(s));
          }
          s[t] = '0';
        }
      }
      s[j] = '0';
    }
  }
}
long long tk1(vector<long long> &a, long long l, long long r, long long x) {
  if (l > r) return l;
  long long m = (l + r) / 2;
  if (a[m] == x) return m;
  if (a[m] < x) return tk1(a, m + 1, r, x);
  if (a[m] > x) return tk1(a, l, m - 1, x);
}
long long tk2(vector<long long> &a, long long l, long long r, long long x) {
  if (l > r) return r;
  long long m = (l + r) / 2;
  if (a[m] == x) return m;
  if (a[m] < x) return tk2(a, m + 1, r, x);
  if (a[m] > x) return tk2(a, l, m - 1, x);
}
int main() {
  long long q, t, i, l, r, vt1, vt2;
  cin >> q;
  for (i = 0; i <= 99; i++) v.push_back(i);
  for (i = 3; i <= 19; i++) kt(i);
  set<long long> s(v.begin(), v.end());
  vector<long long> v(s.begin(), s.end());
  for (i = 1; i <= q; i++) {
    cin >> l >> r;
    vt1 = tk1(v, 0, v.size() - 1, l);
    vt2 = tk2(v, 0, v.size() - 1, r);
    cout << vt2 - vt1 + 1 << endl;
  }
  return 0;
}