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;
inline long long read() {
  long long ans = 0;
  char r = getchar();
  bool neg = false;
  while (r < '0' || r > '9') {
    if (r == '-') neg = true;
    r = getchar();
  }
  while (r >= '0' && r <= '9') {
    ans = ans * 10 + r - '0';
    r = getchar();
  }
  return (neg) ? -ans : ans;
}
void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
const int mod = 2520;
long long dp[20][3000][50];
int num[20], vis[2550];
long long dfs(int pos, bool limit, int sta, int lcm) {
  if (!pos) return sta % lcm == 0;
  if (!limit && dp[pos][sta][vis[lcm]] != -1) return dp[pos][sta][vis[lcm]];
  int up = limit ? num[pos] : 9;
  long long ans = 0;
  for (int i = 0; i <= up; i++) {
    ans += dfs(pos - 1, limit && i == up, (sta * 10 + i) % mod,
               i ? (lcm * i / gcd(lcm, i)) : lcm);
  }
  if (!limit) dp[pos][sta][vis[lcm]] = ans;
  return ans;
}
long long solve(long long a) {
  int len = 0;
  while (a) {
    num[++len] = a % 10;
    a /= 10;
  }
  return dfs(len, true, 0, 1);
}
int main() {
  int tot = 0;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) vis[i] = tot++;
  }
  long long t;
  t = read();
  while (t--) {
    long long a, b;
    a = read(), b = read();
    write(solve(b) - solve(a - 1));
    putchar('\n');
  }
  return 0;
}