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 double pi = acos(-1.0);
const int MOD = 2520;
int dig[20];
int idx[MOD + 3];
long long int dp[20][2525][50];
inline long long int gcd(long long int m, long long int n) {
  return n ? gcd(n, m % n) : m;
}
inline long long int lcm(long long int m, long long int n) {
  return m / gcd(m, n) * n;
}
void discretize() {
  int cnt = 0;
  for (int i = 1; i <= MOD; i++)
    if (MOD % i == 0) {
      idx[i] = ++cnt;
    }
}
long long int dfs(int pos, int mod, int Lcm, bool limit) {
  if (pos == 0) return mod % Lcm == 0;
  if (!limit && dp[pos][mod][idx[Lcm]] != -1) return dp[pos][mod][idx[Lcm]];
  int up = limit ? dig[pos] : 9;
  long long int ans = 0;
  for (int i = 0; i <= up; i++) {
    if (i == 0)
      ans += dfs(pos - 1, (mod * 10 + i) % MOD, Lcm, limit && i == up);
    else
      ans += dfs(pos - 1, (mod * 10 + i) % MOD, lcm(Lcm, i), limit && i == up);
  }
  if (!limit) dp[pos][mod][idx[Lcm]] = ans;
  return ans;
}
long long int solve(long long int x) {
  int len = 0;
  while (x) {
    dig[++len] = x % 10;
    x /= 10;
  }
  return dfs(len, 0, 1, 1);
}
int main() {
  discretize();
  int t;
  scanf("%d", &t);
  memset(dp, -1, sizeof(dp));
  while (t--) {
    long long int l, r;
    cin >> l >> r;
    cout << solve(r) - solve(l - 1) << endl;
  }
}