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>
int p[200];
int cnt;
long long dp[22][2520][55];
int bit[22];
void init() {
  cnt = 0;
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) p[++cnt] = i;
  }
  memset(dp, -1, sizeof(dp));
}
int GCD(int a, int b) {
  while (a % b) {
    int tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
int LCM(int a, int b) { return a / GCD(a, b) * b; }
int search(int x) {
  for (int i = 1; i <= cnt; i++)
    if (p[i] == x) return i;
  int l = 1, r = cnt;
  while (l < r) {
    int mid = (l + r) / 2;
    if (p[mid] == x) return mid;
    if (p[mid] >= x)
      r = mid;
    else
      l = mid + 1;
  }
  return l;
}
long long dfs(int pos, int mod, int id, bool flag) {
  if (pos <= 0) return (mod % p[id] == 0);
  if (!flag && dp[pos][mod][id] != -1) return dp[pos][mod][id];
  int tmp = flag ? bit[pos] : 9;
  long long res = 0;
  for (int i = 0; i <= tmp; i++) {
    int r = (10 * mod + i) % 2520;
    int idd = id;
    if (i) idd = search(LCM(p[id], i));
    res += dfs(pos - 1, r, idd, flag && (i == tmp));
  }
  if (!flag) dp[pos][mod][id] = res;
  return res;
}
long long calc(long long x) {
  int len = 0;
  while (x) {
    bit[++len] = x % 10;
    x /= 10;
  }
  return dfs(len, 0, 1, true);
}
int main() {
  int cas;
  init();
  scanf("%d", &cas);
  while (cas--) {
    long long x, y;
    scanf("%I64d%I64d", &x, &y);
    printf("%I64d\n", calc(y) - calc(x - 1));
  }
  return 0;
}