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>
long long int p = 0, len;
long long int f(char s[]) {
  long long int cnt = 0, i, r, d, val = 0;
  len = strlen(s);
  if (len <= 3) {
    if (len == 3)
      val = (s[0] - '0') * 100 + (s[1] - '0') * 10 + (s[2] - '0');
    else if (len == 2)
      val = (s[0] - '0') * 10 + (s[1] - '0');
    else
      val = s[0] - '0';
    return val;
  } else {
    val = ((len - 1) * (len - 2) * (len - 3) * 9 * 9 * 9) / 6 +
          ((len - 1) * (len - 2) * 9 * 9) / 2 + (len - 1) * 9;
    p = 0;
    cnt = 0;
    for (i = 0; i < len; i++) {
      if (s[i] != '0') p++;
      if (s[i] != '0' & cnt < 3) {
        cnt++;
        r = len - i - 1;
        d = s[i] - '0';
        if (cnt == 1) {
          if (r > 0) val = val + (d - 1) * ((r * (r - 1) * 81) / 2 + r * 9 + 1);
        }
        if (cnt == 2) {
          if (r > 0) {
            val = val + (d - 1) * (9 * r + 1);
            val = val + ((r * (r - 1) * 81) / 2 + 9 * r + 1);
          } else {
            val = val + (d - 1);
            val = val + 1;
          }
        }
        if (cnt == 3) {
          if (r > 0) {
            val = val + (d - 1);
            val = val + (r * 9 + 1);
          } else {
            val = val + (d - 1);
            val = val + 1;
          }
        }
      }
    }
    val = val + 1;
    return val;
  }
}
int main() {
  long long int Q, res1, res2, result;
  char s1[20];
  char s2[20];
  scanf("%lld", &Q);
  while (Q--) {
    scanf("%s", s1);
    scanf("%s", s2);
    res1 = f(s1);
    if (p <= 3 || len <= 3) res1 = res1 - 1;
    res2 = f(s2);
    result = res2 - res1;
    printf("%lld\n", result);
  }
  return 0;
}