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 mm = 2520;
long long n, m;
long long dp[20][2550][110];
int h1[3300], h2[110];
int cnt;
int gcd(int xx, int yy) {
  if (yy == 0)
    return xx;
  else
    return gcd(yy, xx % yy);
}
void hhash(int num) {
  if (h1[num] == 0) {
    h1[num] = ++cnt;
    h2[cnt] = num;
  }
}
int len, digit[20];
long long dfs(int len, int mod, int bnum, int limit) {
  if (len == 0) {
    if (mod % h2[bnum] == 0) {
      return 1;
    } else
      return 0;
  }
  if (!limit && dp[len][mod][bnum] != -1) return dp[len][mod][bnum];
  int maxdig = limit ? digit[len] : 9;
  long long ret = 0;
  for (int i = 0; i <= maxdig; i++) {
    int bb;
    if (i != 0) {
      bb = (h2[bnum] * i) / gcd(h2[bnum], i);
      hhash(bb);
    } else
      bb = h2[bnum];
    ret += dfs(len - 1, (mod * 10 + i) % mm, h1[bb], limit && i == maxdig);
  }
  if (!limit) dp[len][mod][bnum] = ret;
  return ret;
}
long long f(long long x) {
  len = 0;
  while (x) {
    digit[++len] = x % 10;
    x /= 10;
  }
  return dfs(len, 0, 0, 1);
}
int main() {
  int cas;
  scanf("%d", &cas);
  memset(h1, 0, sizeof(h1));
  memset(h2, 0, sizeof(h2));
  h2[0] = 1;
  h1[1] = 0;
  memset(dp, -1, sizeof(dp));
  cnt = 0;
  while (cas--) {
    scanf("%I64d%I64d", &n, &m);
    printf("%I64d\n", f(m) - f(n - 1));
  }
  return 0;
}