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 len;
int num[30];
int has[2550];
long long dp[30][2550][50];
int gcd(int a, int b) {
  if (!b)
    return a;
  else
    return gcd(b, a % b);
}
int llcm(int a, int b) { return a / gcd(a, b) * b; }
long long dfs(int pos, int mod, int lcm, int limit) {
  if (pos < 0) return mod % lcm == 0;
  if (!limit && dp[pos][mod][has[lcm]] != -1) {
    return dp[pos][mod][has[lcm]];
  }
  int endi = 9;
  if (limit) endi = num[pos];
  long long res = 0;
  int tlcm;
  for (int i = 0; i <= endi; i++) {
    if (!i)
      tlcm = lcm;
    else
      tlcm = llcm(lcm, i);
    res += dfs(pos - 1, (mod * 10 + i) % 2520, tlcm, limit && (i == endi));
  }
  if (!limit) dp[pos][mod][has[lcm]] = res;
  return res;
}
long long solve(long long n) {
  len = 0;
  while (n) {
    num[len++] = n % 10;
    n /= 10;
  }
  return dfs(len - 1, 0, 1, 1);
}
void init() {
  memset(has, 0, sizeof(has));
  int tem;
  for (int i = 0; i < (1 << 9); i++) {
    tem = 1;
    for (int j = 1; j <= 9; j++) {
      if (i & (1 << j)) tem = llcm(tem, j + 1);
    }
    has[tem] = 1;
  }
  int l = 0;
  for (int i = 0; i <= 2520; i++)
    if (has[i]) has[i] = l++;
}
int main() {
  init();
  memset(dp, -1, sizeof(dp));
  int _;
  scanf("%d", &_);
  while (_--) {
    long long n, m;
    scanf("%I64d%I64d", &m, &n);
    printf("%I64d\n", solve(n) - solve(m - 1));
  }
  return 0;
}