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 long long OO = (long long)(1e18) + 9;
const long long MOD = (long long)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-9;
const double PI = acos(-1.0);
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int dX[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dY[] = {0, 1, 0, -1, 1, 1, -1, -1};
string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiou";
int dcmp(long double d1, long double d2) {
  return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1;
}
long long gcd(long long x, long long y) { return !y ? x : gcd(y, x % y); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
int ord(int r, int c, int nCol) { return (nCol * r) + c + 1; }
pair<int, int> rord(int n, int nCol) {
  int r = n % nCol, c = n / nCol;
  if (n % nCol == 0) c--, r = nCol;
  return pair<int, int>(r, c);
}
long long poww(long long num, long long p, long long md) {
  num %= md;
  long long ret = 1;
  while (p > 0) {
    if (p & 1) ret = (ret * num) % md;
    num = (num * num) % md;
    p >>= 1;
  }
  return ret;
}
long long nCr(long long n, long long r) {
  if (n < r) return 0;
  if (r == 0) return 1;
  return n * nCr(n - 1, r - 1) / r;
}
long long dp[20][10][2][2];
string L, R;
long long solve(int idx, int rest, int l, int r) {
  if (rest < 0) return 0;
  if (idx == (int)R.size()) return 1;
  long long& tmp = dp[idx][rest][l][r];
  if (~tmp) return tmp;
  tmp = 0;
  for (int i = 0; i < 10; i++) {
    if (!l && i < L[idx] - '0') continue;
    if (!r && i > R[idx] - '0') continue;
    tmp += solve(idx + 1, rest - (i != 0), l || (i > L[idx] - '0'),
                 r || (i < R[idx] - '0'));
  }
  return tmp;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    memset(dp, -1, sizeof dp);
    cin >> L >> R;
    int dif = (int)R.size() - (int)L.size();
    while (dif--) L = "0" + L;
    printf("%lld\n", solve(0, 3, 0, 0));
  }
  return 0;
}