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>
long long dp[20][2520][50];
int digit[20];
int id[2521];
int tot;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int LCM(int a, int b) { return a / GCD(a, b) * b; }
void init_LCM() {
  tot = 0;
  for (int i = 1; i <= 2520; ++i) {
    if (2520 % i == 0) {
      id[i] = ++tot;
    }
  }
}
long long DFS(int pos, int val, int lcm, bool limit) {
  if (pos == -1) {
    return val % lcm == 0;
  }
  long long &now = dp[pos][val][id[lcm]];
  if (!limit && now != -1) {
    return now;
  }
  int d = limit ? digit[pos] : 9;
  long long ret = 0;
  for (int i = 0; i <= d; ++i) {
    int tval = (val * 10 + i) % 2520;
    int tlcm = i ? lcm / GCD(lcm, i) * i : lcm;
    ret += DFS(pos - 1, tval, tlcm, limit && i == d);
  }
  if (!limit) {
    now = ret;
  }
  return ret;
}
long long solve(long long x) {
  int len = 0;
  if (x == 0) {
    digit[len++] = 0;
  } else {
    while (x) {
      digit[len++] = x % 10;
      x /= 10;
    }
  }
  return DFS(len - 1, 0, 1, true);
}
int main() {
  init_LCM();
  memset(dp, -1, sizeof(dp));
  int T;
  scanf("%d", &T);
  while (T--) {
    long long l, r;
    std::cin >> l >> r;
    std::cout << solve(r) - solve(l - 1) << '\n';
  }
  return 0;
}