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>
long long dp[20][50][252];
int bit[20], mp[2522], b[55];
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline long long dfs(int pos, int s, int mod, int e) {
  if (pos < 1) return mod % s == 0;
  if (!e && ~dp[pos][mp[s]][mod]) return dp[pos][mp[s]][mod];
  int mx = e ? bit[pos] : 9, i;
  long long ret = 0;
  for (i = 0; i <= mx; ++i)
    ret += dfs(pos - 1, i ? s / gcd(s, i) * i : s,
               pos > 1 ? ((mod << 1) + (mod << 3) + i) % 252
                       : ((mod << 1) + (mod << 3) + i),
               e && i == mx);
  return e ? ret : dp[pos][mp[s]][mod] = ret;
}
inline long long work(long long val) {
  int len = 0;
  for (; val; val /= 10) bit[++len] = val % 10;
  return dfs(len, 1, 0, 1);
}
int main() {
  long long n, m = 0;
  memset(dp, -1, sizeof dp);
  int t;
  for (t = 1; t <= 2520; ++t)
    if (2520 % t == 0) mp[t] = m, b[m++] = t;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld%lld", &n, &m);
    printf("%lld\n", work(m) - work(n - 1));
  }
  return 0;
}