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][1 << 8][2520];
int num[20];
long long dfs(int pos, int occu, int rem, int lim) {
  if (!lim)
    if (dp[pos][occu][rem] + 1) return dp[pos][occu][rem];
  if (pos == 0) {
    for (int i = 0; i < 8; i++)
      if ((occu & (1 << i)) && (rem % (i + 2))) return 0;
    return 1;
  }
  long long tmp = 0;
  int upper = lim ? num[pos] : 9;
  for (int i = 0; i <= upper; i++)
    tmp += dfs(pos - 1, occu | ((i > 1) ? (1 << i - 2) : 0),
               (rem * 10 + i) % 2520, lim && (i == num[pos]));
  if (!lim) dp[pos][occu][rem] = tmp;
  return tmp;
}
long long count(long long x) {
  if (x == 0) return 0;
  memset(num, 0, sizeof num);
  int p = 0;
  while (x) {
    ++p;
    num[p] = x % 10;
    x /= 10;
  }
  return dfs(p, 0, 0, 1) - 1;
}
int main(int argc, char const *argv[]) {
  int T;
  long long l, r;
  scanf("%d", &T);
  memset(dp, -1, sizeof dp);
  while (T--) {
    scanf("%I64d%I64d", &l, &r);
    printf("%I64d\n", count(r) - count(l - 1));
  }
  return 0;
}