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 INF = 0x3f3f3f3f;
const double eps = 1E-8;
const int mod = 2520;
int idx[2521];
char dig[20];
long long dp[20][2520][48];
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long dfs(int pos, int presum, int prelcm, bool bound) {
  if (pos == -1) return presum % prelcm == 0;
  if (!bound && ~dp[pos][presum][idx[prelcm]])
    return dp[pos][presum][idx[prelcm]];
  int end = bound ? dig[pos] - '0' : 9;
  long long ret = 0;
  int nowsum, nowlcm = prelcm;
  for (int i = 0; i <= end; i++) {
    nowsum = (presum * 10 + i) % mod;
    if (i) nowlcm = lcm(prelcm, i);
    ret += dfs(pos - 1, nowsum, nowlcm, bound && i == end);
  }
  if (!bound) dp[pos][presum][idx[prelcm]] = ret;
  return ret;
}
long long cal(long long a) {
  sprintf(dig, "%I64d", a);
  int len = strlen(dig);
  reverse(dig, dig + len);
  return dfs(len - 1, 0, 1, 1);
}
int main() {
  long long l, r;
  int c = 0;
  (memset(dp, -1, sizeof(dp)));
  for (int i = 1; i <= mod; i++)
    if (mod % i == 0) idx[i] = c++;
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%I64d%I64d", &l, &r);
    if (l == 0 && r == 0) break;
    long long ans1 = cal(r);
    long long ans2 = cal(l - 1);
    long long ans = ans1 - ans2;
    printf("%I64d\n", ans);
  }
  return 0;
}