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 mod = 2520;
long long dp[20][100][2530];
int a[20];
long long n, m;
int vis[2530];
long long __gcd(long long a, long long b) {
  if (b == 0) return a;
  return __gcd(b, a % b);
}
long long lcm(long long n, long long m) { return n / __gcd(n, m) * m; }
long long dfs(int pos, int lcm_, int sta, bool limit) {
  if (pos == 0) return sta % lcm_ == 0;
  if (!limit && dp[pos][vis[lcm_]][sta] != -1) return dp[pos][vis[lcm_]][sta];
  int up = limit ? a[pos] : 9;
  long long tmp = 0;
  for (int i = 0; i <= up; ++i) {
    int _sta = (sta * 10 + i) % mod;
    if (i) {
      int _lcm = lcm(lcm_, i);
      tmp += dfs(pos - 1, _lcm, _sta, i == up && limit);
    } else
      tmp += dfs(pos - 1, lcm_, _sta, i == up && limit);
  }
  if (!limit) dp[pos][vis[lcm_]][sta] = tmp;
  return tmp;
}
long long solve(long long x) {
  int pos = 1;
  while (x) {
    a[pos++] = x % 10;
    x /= 10;
  }
  return dfs(pos - 1, 1, 0, true);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    memset(dp, -1, sizeof(dp));
    memset(vis, 0, sizeof(vis));
    int p = 0;
    for (int i = 1; i <= 2520; i++)
      if (mod % i == 0) vis[i] = ++p;
    scanf("%lld%lld", &n, &m);
    printf("%lld\n", solve(m) - solve(n - 1));
  }
  return 0;
}