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;
template <typename T>
bool chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
bool chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
const int maxl = 100;
const int maxx = 2520;
int tot;
int lcm[maxl], LCM[maxl][20], s[20];
long long dp[20][maxx + 100][maxl];
map<int, int> ma;
inline void file() {
  freopen("CF55D.in", "r", stdin);
  freopen("CF55D.out", "w", stdout);
}
inline void read(int &x) {
  x = 0;
  int p = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c - '0');
    c = getchar();
  }
  x *= p;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
inline void init() {
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= maxx; ++i)
    if (maxx % i == 0) {
      lcm[++tot] = i;
      ma[i] = tot;
    }
  for (int i = 1; i <= tot; ++i) {
    LCM[i][0] = i;
    for (int j = 1; j <= 9; ++j) LCM[i][j] = ma[lcm[i] * j / gcd(lcm[i], j)];
  }
  for (int j = 0; j <= 9; ++j) LCM[0][j] = j;
}
long long DFS(int k, int pres, int prel, int flag) {
  if (k == 0) {
    if (!prel) return 0;
    return pres % lcm[prel] == 0;
  }
  if (!flag && dp[k][pres][prel] != -1) return dp[k][pres][prel];
  long long ans = 0;
  int nn = flag ? s[k] : 9;
  for (int i = 0; i <= nn; ++i) {
    int nows = (10 * pres + i) % maxx;
    int nowl = LCM[prel][i];
    ans += DFS(k - 1, nows, nowl, (flag && i == nn));
  }
  if (!flag) dp[k][pres][prel] = ans;
  return ans;
}
long long calc(long long x) {
  int k = 0;
  while (x) {
    s[++k] = x % 10;
    x /= 10;
  }
  return DFS(k, 0, 0, 1);
}
int main() {
  init();
  int tt;
  scanf("%d", &tt);
  while (tt--) {
    long long L, R;
    cin >> L >> R;
    long long ans = calc(R) - calc(L - 1);
    cout << ans << endl;
  }
  return 0;
}