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 digit[20], cnt, cont, Hash[2525];
long long int dp[20][50][2525];
void init() {
  cont = 0;
  memset(dp, -1, sizeof(dp));
  memset(Hash, 0, sizeof(Hash));
  for (int i = 1; i <= MOD; i++) {
    if (MOD % i == 0) Hash[i] = ++cont;
  }
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int LCM(int a, int b) { return a / gcd(a, b) * b; }
long long int dfs(int pos, int lcm, int left, bool limit) {
  if (pos == -1) return left % lcm == 0;
  if (!limit && dp[pos][Hash[lcm]][left] != -1) return dp[pos][Hash[lcm]][left];
  int up = limit ? digit[pos] : 9;
  long long int ret = 0;
  for (int i = 0; i <= up; i++) {
    int nowleft = (left * 10 + i) % MOD;
    int nowlcm = lcm;
    if (i) nowlcm = LCM(lcm, i);
    ret += dfs(pos - 1, nowlcm, nowleft, limit && i == up);
  }
  if (!limit) dp[pos][Hash[lcm]][left] = ret;
  return ret;
}
long long int solve(long long int x) {
  cnt = 0;
  while (x) {
    digit[cnt++] = x % 10;
    x /= 10;
  }
  return dfs(cnt - 1, 1, 0, true);
}
int main() {
  int T;
  init();
  long long int L, R;
  cin >> T;
  while (T--) {
    cin >> L >> R;
    cout << solve(R) - solve(L - 1) << endl;
  }
  return 0;
}