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[25][mod + 10][50], l, r;
int book[mod + 10];
vector<int> shu;
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
void init() {
  int cnt = 0;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= mod; i++) {
    if (mod % i == 0) book[i] = ++cnt;
  }
}
long long dfs(int pos, int he, int lcm, int sp) {
  if (pos == -1) {
    return he % lcm == 0;
  }
  if (!sp && dp[pos][he][book[lcm]] != -1) return dp[pos][he][book[lcm]];
  long long ans = 0;
  int maxn = sp == 1 ? shu[pos] : 9;
  for (int i = 0; i <= maxn; i++) {
    int next_he = (he * 10 + i) % mod;
    int next_lcm = lcm;
    if (i) next_lcm = lcm * i / gcd(lcm, i);
    ans += dfs(pos - 1, next_he, next_lcm, sp && i == maxn);
  }
  if (!sp) dp[pos][he][book[lcm]] = ans;
  return ans;
}
long long cal(long long num) {
  shu.clear();
  while (num) {
    shu.push_back(num % 10);
    num /= 10;
  }
  return dfs(shu.size() - 1, 0, 1, 1);
}
int main() {
  int t;
  cin >> t;
  init();
  while (t--) {
    cin >> l >> r;
    cout << cal(r) - cal(l - 1) << endl;
  }
}