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 dp[65][3000][50];
long long a[65];
map<long long, long long> hashmap;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (!b) return a;
  return gcd(b, a % b);
}
long long dfs(int pos, long long sum, long long pre, bool limit) {
  if (pos == -1) return (sum % (pre) == 0);
  if (!limit && dp[pos][sum][hashmap[pre]] != -1)
    return dp[pos][sum][hashmap[pre]];
  long long up = limit ? a[pos] : 9;
  long long ans = 0;
  for (long long i = 0; i <= up; ++i) {
    if (i == 0)
      ans += dfs(pos - 1, sum * 10 % 2520, pre, limit && a[pos] == i);
    else
      ans += dfs(pos - 1, (sum * 10 + i) % (long long)2520,
                 pre * i / gcd(pre, i), limit && a[pos] == i);
  }
  if (!limit) dp[pos][sum][hashmap[pre]] = ans;
  return ans;
}
long long solve(long long x) {
  int pos = 0;
  if (x == 0)
    a[0] = 0, pos = 1;
  else
    while (x) {
      a[pos++] = x % 10;
      x /= 10;
    }
  return dfs(pos - 1, 0, 1, true);
}
int main() {
  int kase;
  cin >> kase;
  memset(dp, -1, sizeof(dp));
  for (long long i = 1, j = 0; i <= 2520; ++i)
    if ((long long)2520 % i == 0) hashmap[i] = j++;
  while (kase--) {
    long long l, r;
    cin >> l >> r;
    cout << solve(r) - solve(l - 1) << endl;
  }
  return 0;
}