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;
long long dp[30][3000][60], num[30], indexx[3000], cnt;
const long long mod = 2520LL;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long dfs(long long pos, long long presum, long long prelcm, bool flag) {
  if (pos == 0) return presum % prelcm == 0;
  if (flag && dp[pos][presum][indexx[prelcm]] != -1)
    return dp[pos][presum][indexx[prelcm]];
  long long u = flag ? 9 : num[pos];
  long long ans = 0;
  for (long long d = 0; d <= u; d++) {
    long long newsum = (presum * 10 + d) % mod;
    long long newlcm = prelcm;
    if (d) newlcm = lcm(d, newlcm);
    ans += dfs(pos - 1, newsum, newlcm, flag || d < u);
  }
  if (flag) dp[pos][presum][indexx[prelcm]] = ans;
  return ans;
}
long long solve(long long x) {
  long long len = 0;
  while (x) {
    num[++len] = x % 10;
    x /= 10;
  }
  return dfs(len, 0, 1, 0);
}
int main() {
  long long T, A, B;
  cnt = 0;
  for (long long i = 1; i <= mod; i++)
    if (mod % i == 0) indexx[i] = cnt++;
  memset(dp, -1, sizeof(dp));
  cin >> T;
  while (T--) {
    cin >> A >> B;
    cout << solve(B) - solve(A - 1) << endl;
  }
}