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;
long long dp[20][2530][50], dight[20];
map<int, int> mp;
int cnt;
int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }
long long dfs(int pos, int rem, int chu, int limit) {
  if (pos < 0) return rem % chu == 0;
  if (!limit && dp[pos][rem][mp[chu]] != -1) return dp[pos][rem][mp[chu]];
  long long ed, ret = 0;
  if (limit)
    ed = dight[pos];
  else
    ed = 9;
  for (long long i = 0; i <= ed; i++) {
    if (i) {
      ret += dfs(pos - 1, (rem * 10 + i) % mod, chu * i / gcd(chu, i),
                 limit && i == ed);
    } else {
      ret += dfs(pos - 1, (rem * 10 + i) % mod, chu, limit && i == ed);
    }
  }
  if (!limit) dp[pos][rem][mp[chu]] = ret;
  return ret;
}
long long cal(long long x) {
  int pos = 0;
  while (x) {
    dight[pos++] = x % 10;
    x /= 10;
  }
  return dfs(pos - 1, 0, 1, 1);
}
int main() {
  memset(dp, -1, sizeof(dp));
  cnt = 0;
  for (int i = 1; i <= mod; i++) {
    if (mod % i == 0) mp[i] = cnt++;
  }
  int t;
  cin >> t;
  long long a, b;
  while (t--) {
    cin >> a >> b;
    cout << cal(b) - cal(a - 1) << endl;
  }
}