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;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << " = " << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << " = " << h << ", ";
  _dbg(sdbg + 1, a...);
}
const int maxn = (1e6) + 7;
const int maxk = 20;
const int inf = (1e9) + 7;
const long long LLinf = (1e18) + 7;
const long double eps = 1e-9;
const long long mod = 1e9 + 7;
vector<vector<int> > V, V2, V3;
vector<long long> xd;
set<long long> cnt;
long long N = 17;
long long dzi[maxn];
long long ile(long long P) {
  int l = -1;
  int p = ((int)(xd).size());
  while (l + 1 < p) {
    int sr = (l + p) / 2;
    if (xd[sr] <= P)
      l = sr;
    else
      p = sr;
  }
  return p;
}
void solve() {
  long long l, p;
  cin >> l >> p;
  cout << ile(p) - ile(l - 1) << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  dzi[0] = 1;
  for (int i = 1; i <= N; i++) dzi[i] = dzi[i - 1] * 10LL;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      for (int k = 1; k < 10; k++) V.push_back({i, j, k});
  for (int i = 0; i <= N; i++)
    for (int j = i; j <= N; j++)
      for (int k = j; k <= N; k++) {
        for (auto s : V)
          cnt.insert(dzi[i] * s[0] + dzi[j] * s[1] + dzi[k] * s[2]);
      }
  for (auto s : cnt) xd.push_back(s);
  int q;
  cin >> q;
  while (q--) solve();
  return 0;
}