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 p = 2520;
int t;
long long n, m, dp[20][2600][50];
int a[20], b[2600];
int gcd(int q, int w) {
  if (!w) return q;
  return gcd(w, q % w);
}
int Lcm(int q, int w) { return (q * w) / gcd(q, w); }
long long dfs(int pos, int pre, int lcm, bool limit) {
  if (pos == 0) return pre % lcm == 0;
  if (!limit && dp[pos][pre][b[lcm]] != -1) return dp[pos][pre][b[lcm]];
  int up = limit ? a[pos] : 9;
  long long res = 0;
  for (int i = 0; i <= up; i++) {
    res += dfs(pos - 1, (pre * 10 + i) % p, i ? Lcm(lcm, i) : lcm,
               limit && i == a[pos]);
  }
  if (!limit) dp[pos][pre][b[lcm]] = res;
  return res;
}
long long solve(long long x) {
  int pos = 0;
  while (x) {
    a[++pos] = x % 10;
    x /= 10;
  }
  return dfs(pos, 0, 1, true);
}
int main() {
  memset(dp, -1, sizeof(dp));
  int cnt = 0;
  for (int i = 1; i <= p; i++) {
    if (p % i == 0) b[i] = ++cnt;
  }
  cin >> t;
  while (t--) {
    cin >> n >> m;
    cout << solve(m) - solve(n - 1) << endl;
  }
}