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>
using namespace std;
int t, k;
long long pw8[1010];
long long f[1010][2];
char L[1010], R[1010];
void pre_cal() {
  pw8[0] = 1;
  for (int i = 1; i <= 1000; i++) pw8[i] = pw8[i - 1] * 8 % 1000000007;
  memset(f, 0, sizeof(f));
  f[1][1] = 8;
  f[1][0] = 2;
  f[0][0] = 1;
  for (int len = 2; len <= 1000; len++) {
    for (int i = min(k + 1, len); i <= len; i++)
      f[len][0] = (f[len][0] + 2 * (f[len - i][0] * pw8[i - 1])) % 1000000007;
    f[len][1] = (8 * (f[len - 1][1] + f[len - 1][0])) % 1000000007;
  }
}
long long cal(char *s) {
  int len = strlen(s);
  long long total = 0, anti = 0;
  for (int i = 0; s[i]; i++) total = (total * 10 + s[i] - '0') % 1000000007;
  int last = -0x3fffffff;
  for (int i = 0; i < len; i++) {
    char end = (i == len - 1 ? s[i] : s[i] - 1);
    for (char j = '0'; j <= end; j++) {
      int near = last;
      if (j == '4' || j == '7') {
        near = i;
        if (i - last <= k) continue;
      }
      int pos = near + k + 1;
      if (pos > len) pos = len;
      if (pos <= i) {
        anti = (anti + (f[len - i - 1][0] + f[len - i - 1][1])) % 1000000007;
      } else {
        anti = (anti + pw8[pos - i - 1] * (f[len - pos][0] + f[len - pos][1])) %
               1000000007;
      }
    }
    if (s[i] == '4' || s[i] == '7') {
      if (i - last <= k) break;
      last = i;
    }
  }
  return ((total - anti) % 1000000007 + 1000000007) % 1000000007;
}
bool check(char *s) {
  int last = -0x3fffffff;
  for (int i = 0; s[i]; i++) {
    if (s[i] == '4' || s[i] == '7') {
      if (i - last <= k) return true;
      last = i;
    }
  }
  return false;
}
int main() {
  while (scanf("%d%d", &t, &k) != EOF) {
    pre_cal();
    while (t--) {
      scanf("%s%s", L, R);
      long long d1 = cal(L);
      long long d2 = cal(R);
      if (check(L)) d2++;
      cout << ((d2 - d1) % 1000000007 + 1000000007) % 1000000007 << endl;
    }
  }
  return 0;
}