Problem: Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not.

You are given a segment [L; R]. Count the number of classy integers x such that L ≤ x ≤ R.

Each testcase contains several segments, for each of them you are required to solve the problem separately.

Input

The first line contains a single integer T (1 ≤ T ≤ 10^4) — the number of segments in a testcase.

Each of the next T lines contains two integers L_i and R_i (1 ≤ L_i ≤ R_i ≤ 10^{18}).

Output

Print T lines — the i-th line should contain the number of classy integers on a segment [L_i; R_i].

Example

Input

4
1 1000
1024 1024
65536 65536
999999 1000001


Output

1000
1
0
2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int T;
long long f[20][10][4], g[20][10][4], a[20], l, r;
long long find(long long r) {
  long long x = r, t = 0, p = 3;
  while (x) a[++t] = x % 10LL, x /= 10LL;
  long long ans = 0;
  for (int i = t; i >= 1; --i) {
    if (a[i]) {
      for (int j = 0; j <= p; ++j) ans += g[i][a[i] - 1][j];
      p--;
    }
    if (p < 0) break;
  }
  if (p >= 0) ans++;
  return ans;
}
int main() {
  scanf("%d\n", &T);
  f[1][0][0] = 1;
  for (int j = 1; j <= 9; ++j) f[1][j][1] = 1;
  for (int j = 0; j <= 9; ++j)
    for (int t = 0; t <= 3; ++t)
      g[1][j][t] = (j ? g[1][j - 1][t] : 0) + f[1][j][t];
  for (int i = 2; i <= 19; ++i) {
    for (int t = 0; t <= 3; ++t) f[i][0][t] += g[i - 1][9][t];
    for (int j = 1; j <= 9; ++j) {
      for (int t = 1; t <= 3; ++t) {
        f[i][j][t] += g[i - 1][9][t - 1];
      }
    }
    for (int j = 0; j <= 9; ++j)
      for (int t = 0; t <= 3; ++t)
        g[i][j][t] = (j ? g[i][j - 1][t] : 0) + f[i][j][t];
  }
  long long ans = 0;
  while (T--) {
    scanf("%I64d%I64d\n", &l, &r);
    ans = find(r) - find(l - 1);
    printf("%I64d\n", ans);
  }
  return 0;
}