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 lenl, lenr;
int L[25], R[25];
long long l, r;
long long dp[25][50][2530];
map<int, int> mp;
void get(long long x, int &l, int a[]) {
  l = 0;
  while (x) {
    a[++l] = x % 10;
    x /= 10;
  }
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int cnt = 0;
long long calc(int a[], int pos, int num, long long lcm, int pa, int oa) {
  if (pos == 0) return num % lcm == 0;
  if (pa && dp[pos][mp[lcm]][num] != -1) return dp[pos][mp[lcm]][num];
  long long res = 0;
  for (int i = 0, up = pa ? 9 : a[pos]; i <= up; i++) {
    int tmp = (num * 10 + i) % mod;
    long long g = gcd(lcm, i);
    if (i != 0)
      res += calc(a, pos - 1, tmp, lcm / g * i, pa | (i < a[pos]), oa | i);
    else
      res += calc(a, pos - 1, tmp, lcm, pa | (i < a[pos]), oa | i);
  }
  if (pa) dp[pos][mp[lcm]][num] = res;
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int i, j, t = 0;
  for (i = 1; i <= mod; i++)
    if (mod % i == 0) mp[i] = ++t;
  memset(dp, -1, sizeof(dp));
  cin >> t;
  while (t--) {
    cin >> l >> r;
    if (l > r) swap(l, r);
    get(l - 1, lenl, L), get(r, lenr, R);
    cout << calc(R, lenr, 0, 1, 0, 0) - calc(L, lenl, 0, 1, 0, 0) << endl;
  }
  return 0;
}