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")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
using namespace std;
const long long SIZE = 1e5 + 4, S2 = 1e6 * 2, MOD = 1e9 + 7,
                INF = 1e9 * 1e9 * 2 + 100, P = 28;
multiset<long long> s;
long long curN = 0;
vector<long long> vec;
vector<vector<pair<long long, long long>>> graph;
vector<pair<long long, pair<long long, long long>>> edges, ans;
pair<long long, long long> dsu[SIZE];
long long siz[SIZE];
const long long N = 1e9;
vector<long long> pr;
map<long long, vector<pair<long long, long long>>> rows;
vector<pair<pair<long long, long long>, pair<long long, long long>>> cols;
long long find(string v) {
  pair<long long, long long> dp[4];
  for (int i = 0; i < 4; i++) {
    dp[i].first = 0;
    dp[i].second = 0;
  }
  dp[0].first = 1;
  for (int i = 0; i < v.size(); i++) {
    pair<long long, long long> nw[4];
    for (int j = 0; j < 10; j++) {
      if (j == 0) {
        for (int k = 0; k < 4; k++) {
          if (v[i] == '0') {
            nw[k].first += dp[k].first;
            nw[k].second += dp[k].second;
          } else {
            nw[k].second += dp[k].first + dp[k].second;
          }
        }
      } else {
        for (int k = 1; k < 4; k++) {
          if (v[i] - '0' == j) {
            nw[k].first += dp[k - 1].first;
            nw[k].second += dp[k - 1].second;
          } else if (v[i] - '0' > j) {
            nw[k].second += dp[k - 1].first + dp[k - 1].second;
          } else {
            nw[k].second += dp[k - 1].second;
          }
        }
      }
    }
    for (int j = 0; j < 4; j++) {
      dp[j] = nw[j];
    }
  }
  long long cnt = 0;
  for (int j = 0; j < 4; j++) {
    cnt += dp[j].first + dp[j].second;
  }
  return cnt;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    string r;
    long long l;
    cin >> l >> r;
    cout << find(r) - find(to_string(l - 1)) << "\n";
  }
  return 0;
}