Problem: Petya likes horse racing very much. Horses numbered from l to r take part in the races. Petya wants to evaluate the probability of victory; for some reason, to do that he needs to know the amount of nearly lucky horses' numbers. A nearly lucky number is an integer number that has at least two lucky digits the distance between which does not exceed k. Petya learned from some of his mates from Lviv that lucky digits are digits 4 and 7. The distance between the digits is the absolute difference between their positions in the number of a horse. For example, if k = 2, then numbers 412395497, 404, 4070400000070004007 are nearly lucky and numbers 4, 4123954997, 4007000040070004007 are not.

Petya prepared t intervals [li, ri] and invented number k, common for all of them. Your task is to find how many nearly happy numbers there are in each of these segments. Since the answers can be quite large, output them modulo 1000000007 (109 + 7).

Input

The first line contains two integers t and k (1 ≤ t, k ≤ 1000) — the number of segments and the distance between the numbers correspondingly. Next t lines contain pairs of integers li and ri (1 ≤ l ≤ r ≤ 101000). All numbers are given without the leading zeroes. Numbers in each line are separated by exactly one space character.

Output

Output t lines. In each line print one integer — the answer for the corresponding segment modulo 1000000007 (109 + 7).

Examples

Input

1 2
1 100


Output

4


Input

1 2
70 77


Output

2


Input

2 1
1 20
80 100


Output

0
0

Note

In the first sample, the four nearly lucky numbers are 44, 47, 74, 77.

In the second sample, only 74 and 77 are in the given segment.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
const int MOD = 1000000007;
using namespace std;
int i, j, k, t, n, d[1005], l;
long long ans1, ans2, ans;
char s[1005];
void read_one() {
  scanf("%s", s);
  n = strlen(s);
  for (i = 0; i < n; i++) d[i + 1] = s[i] - '0';
}
void dec() {
  i = n;
  d[i]--;
  while (d[i] < 0) {
    d[i] = 9;
    i--;
    d[i]--;
  }
}
int good[2][1005], sd[2][1005][1005], dp[2][1005][1005];
inline void z(int& A, int B) {
  A += B;
  if (A >= MOD) A -= MOD;
}
inline int ok(int last, int i) { return (last != 0 && i - last <= k); }
int p10[1005];
int cc[1005][1005];
int rec(int n, int dist, int have = 0) {
  if (have) return p10[n];
  if (n <= 0) return 0;
  int& ret = cc[n][dist];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = 0; i < 10; i++) {
    int have2 = 0;
    int dist2 = dist;
    if (i == 4 || i == 7) {
      if (dist2 != 0 && dist2 <= k)
        have2 = 1;
      else
        dist2 = 1;
    } else {
      if (dist2 != 0) dist2++;
    }
    z(ret, rec(n - 1, dist2, have2));
  }
  return ret;
}
int solve() {
  int last = 0, have = 0, ret = 0, will_have, will_last;
  d[n]++;
  for (i = 1; i <= n; i++) {
    for (j = 0; j < d[i]; j++) {
      will_have = have;
      will_last = last;
      if (j == 4 || j == 7)
        if (ok(last, i)) {
          will_have = 1;
        } else
          will_last = i;
      if (will_have) {
        z(ret, p10[n - i]);
      } else
        z(ret, rec(n - i, (will_last == 0) ? 0 : (i + 1 - will_last)));
    }
    if (d[i] == 4 || d[i] == 7) {
      if (ok(last, i)) {
        have = 1;
      } else
        last = i;
    }
  }
  return ret;
}
int main() {
  scanf("%d%d\n", &t, &k);
  memset(cc, -1, sizeof(cc));
  p10[0] = 1;
  for (i = 1; i <= 1003; i++) p10[i] = p10[i - 1] * 10LL % MOD;
  while (t--) {
    read_one();
    dec();
    ans1 = solve();
    read_one();
    ans2 = solve();
    ans = ans2 - ans1;
    ans %= MOD;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
  }
  return 0;
}