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 int MOD = 2520;
int num[22], len, cnt, rec[MOD + 5];
long long dp[22][MOD + 5][55];
int vis[22][MOD + 5][55], tim;
inline int gcd(int x, int y) {
  if (!y) return x;
  return gcd(y, x % y);
}
inline int getlcm(int x, int y) {
  if (!y) return x;
  return x * y / gcd(x, y);
}
inline long long dfs(int dpth, int lcm, int val, int eq) {
  if (val >= MOD) val %= MOD;
  if (dpth < 1) return lcm && ((val % lcm) == 0);
  if (!eq && vis[dpth][val][rec[lcm]]) return dp[dpth][val][rec[lcm]];
  int lim = eq ? num[dpth] : 9, val10 = val * 10;
  long long res = 0;
  for (register int i = 0; i <= lim; ++i)
    res += dfs(dpth - 1, getlcm(lcm, i), val10 + i, eq && (i == num[dpth]));
  if (eq) return res;
  vis[dpth][val][rec[lcm]] = tim;
  return dp[dpth][val][rec[lcm]] = res;
}
inline long long calc(long long n) {
  for (len = 0; n; n /= 10) num[++len] = n % 10;
  ++tim;
  return dfs(len, 1, 0, 1);
}
inline void prc() {
  long long l, r;
  cin >> l >> r;
  --l;
  cout << calc(r) - calc(l) << "\n";
}
inline void init() {
  for (register int i = 1; i <= MOD; ++i)
    if (MOD % i == 0) rec[i] = ++cnt;
}
signed main() {
  init();
  int T;
  cin >> T;
  while (T--) prc();
}