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;
int has[50] = {0,   1,   2,   3,   4,   5,   6,   7,   8,    9,   10,  12,  14,
               15,  18,  20,  21,  24,  28,  30,  35,  36,   40,  42,  45,  56,
               60,  63,  70,  72,  84,  90,  105, 120, 126,  140, 168, 180, 210,
               252, 280, 315, 360, 420, 504, 630, 840, 1260, 2520};
long long dp[25][2550][50];
int wei[30];
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long dfs(int pos, int yushu, int index, int flag) {
  int i, j;
  if (pos == 0) {
    if (yushu % has[index] == 0)
      return 1;
    else
      return 0;
  }
  if (!flag && dp[pos][yushu][index] != -1) return dp[pos][yushu][index];
  int ed = flag ? wei[pos] : 9;
  int yushu1, lcm1, index1;
  long long ans = 0;
  for (i = 0; i <= ed; i++) {
    yushu1 = (yushu * 10 + i) % 2520;
    if (i == 0)
      index1 = index;
    else {
      int lcm = has[index];
      lcm1 = lcm * i / gcd(lcm, i);
      index1 = lower_bound(has, has + 49, lcm1) - has;
    }
    ans += dfs(pos - 1, yushu1, index1, flag && (i == ed));
  }
  if (!flag) dp[pos][yushu][index] = ans;
  return ans;
}
long long solve(long long x) {
  int i, j, len = 0;
  long long t = x;
  while (t) {
    wei[++len] = t % 10;
    t /= 10;
  }
  return dfs(len, 0, 1, 1);
}
int main() {
  int i, j, T;
  long long n, m;
  memset(dp, -1, sizeof(dp));
  scanf("%d", &T);
  while (T--) {
    scanf("%I64d%I64d", &m, &n);
    printf("%I64d\n", solve(n) - solve(m - 1));
  }
  return 0;
}