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 T>
using vec = vector<T>;
const long long inf = pow(2, 62);
const long long mod = 1e9 + 7;
long long dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
long long dy[8] = {0, 1, 0, -1, -1, -1, 1, 1};
long long input() {
  long long tmp;
  cin >> tmp;
  return tmp;
}
string raw_input() {
  string tmp;
  cin >> tmp;
  return tmp;
}
string readline() {
  string s;
  getline(cin, s);
  return s;
}
template <class T>
void printx(T n) {
  cout << n;
}
template <class T, class U>
void printx(pair<T, U> p) {
  cout << "(" << p.first << "," << p.second << ")";
}
template <class T>
void printx(vector<T> v) {
  cout << "{";
  for (long long i = 0; i < v.size(); i++) {
    printx(v[i]);
    if (i != v.size() - 1) printx(",");
  }
  cout << "}";
}
template <class T>
void print(T n) {
  printx(n);
  cout << endl;
}
template <class T>
void print(set<T> s) {
  cout << "{";
  for (auto(e) = s.begin(); (e) != s.end(); (e)++) {
    if (e != s.begin()) printx(",");
    printx(*e);
  }
  cout << "}" << endl;
}
template <class T, class U>
void print(map<T, U> mp) {
  cout << "{";
  for (auto(e) = mp.begin(); (e) != mp.end(); (e)++) {
    cout << "(" << e->first << "," << e->second << ")";
  }
  cout << "}" << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
string a;
long long dp[20][20][2];
long long dfs(long long i, long long cnt, bool m) {
  if (dp[i][cnt][m] > -1) return dp[i][cnt][m];
  if (i == a.size()) {
    if (cnt <= 3)
      return 1;
    else
      return 0;
  }
  long long nxt = a[i] - '0';
  long long ans = 0;
  for (long long j = 0; j <= (m ? nxt : 9); j++) {
    ans += dfs(i + 1, cnt + (j > 0 ? 1 : 0), (m && (j == nxt) ? true : false));
  }
  return dp[i][cnt][m] = ans;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n = input();
  for (long long i = 0; i < n; i++) {
    long long t = input();
    t--;
    a = to_string(t);
    memset(dp, -1, sizeof(dp));
    long long l = dfs(0, 0, true);
    memset(dp, -1, sizeof(dp));
    a = raw_input();
    long long r = dfs(0, 0, true);
    print(r - l);
  }
}