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;
int t;
int m;
int A[35];
long long dp[35][2550][55];
map<int, int> id;
void ID() {
  int m = 0;
  for (int i = 1; i <= 2520; ++i) {
    if (2520 % i == 0) id[i] = ++m;
  }
}
int GCD(int n, int m) {
  if (m == 0) return n;
  return GCD(m, n % m);
}
int LCM(int n, int m) { return n * m / GCD(n, m); }
long long dfs(int pos, int lcm, int mod, int limit) {
  if (pos == 0) return mod % lcm == 0;
  if (!limit && dp[pos][mod][id[lcm]] != -1) return dp[pos][mod][id[lcm]];
  int mx = limit ? A[pos] : 9;
  long long res = 0;
  for (int i = 0; i <= mx; ++i) {
    res += dfs(pos - 1, i == 0 ? lcm : LCM(lcm, i), (mod * 10 + i) % 2520,
               limit & (i == A[pos]));
  }
  if (!limit) dp[pos][mod][id[lcm]] = res;
  return res;
}
long long solve(long long x) {
  m = 0;
  while (x) {
    A[++m] = x % 10;
    x /= 10;
  }
  return dfs(m, 1, 0, 1);
}
int main() {
  ID();
  memset(dp, -1, sizeof(dp));
  cin >> t;
  while (t--) {
    long long l, r;
    cin >> l >> r;
    cout << solve(r) - solve(l - 1) << endl;
  }
}