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;
const int a1[2] = {8, 2};
int i, j, k, n, m, K, x;
int f[1010][1010], h[1010][1010], w[1010];
char p[1010];
inline void M(int &x, int y) { x = (x + y) % 1000000007; }
inline void pre() {
  f[0][0] = 1;
  for (i = 0; i <= 1010 - 5; i++)
    for (j = 0; j <= K + 1; j++)
      if (x = f[i][j]) {
        for (k = 0; k <= 9; k++) {
          int A = k == 4 || k == 7;
          if (j > K)
            M(f[i + 1][K + 1], x);
          else if (!j) {
            if (!A)
              M(f[i + 1][0], x);
            else
              M(f[i + 1][1], x);
          } else {
            if (A)
              M(f[i + 1][K + 1], x);
            else if (j < K)
              M(f[i + 1][j + 1], x);
            else
              M(f[i + 1][0], x);
          }
        }
      }
  for (i = 0; i <= 1010 - 5; i++) {
    h[i][0] = f[i][0];
    for (j = 1; j <= K + 1; j++) h[i][j] = (h[i][j - 1] + f[i][j]) % 1000000007;
  }
  w[0] = 1;
  for (i = 1; i <= 1010 - 5; i++) w[i] = 10ll * w[i - 1] % 1000000007;
}
inline int cal(int ty) {
  scanf("%s", p + 1);
  int n = strlen(p + 1), i, j, an = f[n - 1][K + 1], dis = K + 1;
  for (i = n; i; i--) {
    int l = i == n ? 1 : 0,
        r = (i == 1 ? p[n - i + 1] - ty : p[n - i + 1] - 1) - '0';
    for (j = l; j <= r; j++) {
      int A = j == 4 || j == 7;
      if (A) {
        if (dis == K + 1)
          M(an, (h[i - 1][K + 1] - h[i - 1][0]) % 1000000007);
        else
          M(an, w[i - 1]);
      } else {
        if (!dis)
          M(an, w[i - 1]);
        else {
          M(an, f[i - 1][K + 1]);
          if (dis <= K) M(an, (h[i - 1][dis - 1] - h[i - 1][0]) % 1000000007);
        }
      }
    }
    int w = p[n - i + 1] - '0';
    if (w == 4 || w == 7) {
      if (dis != K + 1)
        dis = 0;
      else
        dis = K;
    } else {
      if (dis && dis <= K) {
        if (dis == 1)
          dis = K + 1;
        else
          dis--;
      }
    }
  }
  return an;
}
int main() {
  scanf("%d%d", &n, &K);
  pre();
  for (i = 1; i <= n; i++) {
    int A = -cal(1);
    A = (A + cal(0)) % 1000000007;
    printf("%d\n", (A + 1000000007) % 1000000007);
  }
  return 0;
}