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;
int q, tot, num[20], hsh[2525];
long long a, b, dp[20][49][2520];
inline int get_lcm(int x, int y) {
  if (y == 0) return x;
  int sav_x = x, sav_y = y, r = x % y;
  while (r > 0) x = y, y = r, r = x % y;
  return sav_x * sav_y / y;
}
inline long long dfs(int len, int lcm, int MO, int flag) {
  if (len == 0) return MO % lcm == 0;
  if (flag != 0 && dp[len][hsh[lcm]][MO] != -1) return dp[len][hsh[lcm]][MO];
  long long ans = 0;
  for (int i = 0; i <= 9; i++) {
    if (flag == 0 && i > num[len]) break;
    ans += dfs(len - 1, get_lcm(lcm, i), (MO * 10 + i) % 2520,
               flag || (i < num[len]));
  }
  if (flag != 0) dp[len][hsh[lcm]][MO] = ans;
  return ans;
}
inline long long wrk(long long x) {
  int len = 0;
  while (x > 0) num[++len] = x % 10, x /= 10;
  return dfs(len, 1, 0, 0);
}
int main() {
  for (int i = 1; i <= 2520; i++)
    if (2520 % i == 0) hsh[i] = ++tot;
  memset(dp, -1, sizeof(dp));
  scanf("%d", &q);
  for (int p = 0; p < q; p++)
    scanf("%lld%lld", &a, &b), printf("%lld\n", wrk(b) - wrk(a - 1));
  return 0;
}