Problem: Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of beautiful numbers in given ranges.

Input

The first line of the input contains the number of cases t (1 ≤ t ≤ 10). Each of the next t lines contains two natural numbers li and ri (1 ≤ li ≤ ri ≤ 9 ·1018).

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).

Output

Output should contain t numbers — answers to the queries, one number per line — quantities of beautiful numbers in given intervals (from li to ri, inclusively).

Examples

Input

1
1 9


Output

9


Input

1
12 15


Output

2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const long long mod = 2520;
vector<long long> dim;
map<long long, long long> m;
long long f[24][2520][52];
long long gcd(long long a, long long b) {
  if (b) {
    return gcd(b, a % b);
  } else {
    return a;
  }
}
long long lcm(long long a, long long b) {
  if (a == 0) {
    return b;
  }
  if (b == 0) {
    return a;
  }
  if (a < b) {
    swap(a, b);
  }
  return a * b / gcd(a, b);
}
void minit() {
  m.clear();
  long long count = 0, i;
  m[0] = ++count;
  for (i = 1; i <= mod; i++) {
    if (mod % i == 0 && m.count(mod / i) == 0) {
      m[mod / i] = ++count;
    }
  }
}
long long dfs(long long pos, long long rest, long long lc, long long limit) {
  if (!pos) {
    if (lc)
      return rest % lc ? 0 : 1;
    else
      return 1;
  }
  if (!limit && f[pos][rest][m[lc]] != -1) return f[pos][rest][m[lc]];
  long long maxx = limit ? dim[pos] : 9, res = 0, i;
  for (i = 0; i <= maxx; i++) {
    res += dfs(pos - 1, (rest + i * (long long)pow(10, pos - 1)) % mod,
               lcm(lc, i), limit && (i == maxx));
  }
  if (!limit) f[pos][rest][m[lc]] = res;
  return res;
}
long long dig(long long x) {
  memset(f, -1, sizeof(f));
  dim.clear();
  dim.push_back(-1);
  while (x) {
    dim.push_back(x % 10);
    x /= 10;
  }
  return dfs(dim.size() - 1, 0, 0, 1);
}
int main(int argc, char const *argv[]) {
  long long t, a, b;
  minit();
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    cin >> a >> b;
    cout << dig(b) - dig(a - 1) << endl;
  }
  return 0;
}