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 long long mod = 1e9 + 7;
long long dp[30][50][2522];
int a[30];
int _hash[2522];
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long dfs(int len, int sta1, int sta2, bool limit) {
  if (len < 0) {
    return sta2 % sta1 == 0 ? 1 : 0;
  }
  if (dp[len][_hash[sta1]][sta2] != -1 && !limit)
    return dp[len][_hash[sta1]][sta2];
  int up = limit ? a[len] : 9;
  long long ans = 0;
  for (int i = 0; i <= up; i++) {
    int t1;
    if (i == 0)
      t1 = sta1;
    else
      t1 = sta1 * i / gcd(i, sta1);
    int t2 = (sta2 * 10 + i) % 2520;
    ans += dfs(len - 1, t1, t2, limit && i == up);
  }
  return limit ? ans : dp[len][_hash[sta1]][sta2] = ans;
}
long long solve(long long x) {
  int cnt = 0;
  while (x > 0) {
    a[cnt++] = x % 10;
    x /= 10;
  }
  return dfs(cnt - 1, 1, 0, 1);
}
int main() {
  long long n, m;
  int T;
  int cnt = 1;
  memset(dp, -1, sizeof dp);
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) _hash[i] = cnt++;
  }
  for (scanf("%d", &T); T--;) {
    scanf("%I64d %I64d", &n, &m);
    printf("%I64d\n", solve(m) - solve(n - 1));
  }
  return 0;
}