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;
long long powmod(long long a, long long b, long long p) {
  if (b < 0) return 0;
  long long res = 1;
  a %= p;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % p;
    a = a * a % p;
  }
  return res;
}
long long dp[19][2522][48];
int id[2521];
int dig[19];
const int moder = 2520;
int gcd(int a, int b) {
  while (b) {
    int t = a % b;
    a = b;
    b = t;
  }
  return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void init() {
  int num = 0;
  for (int i = 1; i <= moder; i++) {
    if (moder % i == 0) id[i] = num++;
  }
  memset(dp, -1, sizeof dp);
}
long long dfs(int pos, int PreSum, int PreLcm, bool up) {
  if (pos < 0) return PreSum % PreLcm == 0;
  long long &res = dp[pos][PreSum][id[PreLcm]];
  if (!up && ~res) return res;
  long long ans = 0;
  int n = up ? dig[pos] : 9;
  for (int i = 0; i <= n; i++) {
    int nowSum = (PreSum * 10 + i) % moder;
    int nowLcm = (i == 0 ? PreLcm : lcm(i, PreLcm));
    ans += dfs(pos - 1, nowSum, nowLcm, up && i == n);
  }
  if (!up) res = ans;
  return ans;
}
long long f(long long x) {
  int pos = 0;
  while (x) {
    dig[pos++] = x % 10;
    x /= 10;
  }
  return dfs(pos - 1, 0, 1, 1);
}
int main() {
  int T;
  scanf("%d", &T);
  init();
  while (T--) {
    long long l, r;
    scanf("%lld%lld", &l, &r);
    printf("%lld\n", f(r) - f(l - 1));
  }
  return 0;
}