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 N = 1020;
const int MOD = 1000000007;
int k;
int dobra(char *txt) {
  int i = 0;
  int last = -1;
  while (txt[i]) {
    if (txt[i] == '4' || txt[i] == '7') {
      if (last != -1 && i - last <= k) return 1;
      last = i;
    }
    i++;
  }
  return 0;
}
int ile[N][N][2];
int wszystkie_dobre[N];
void init() {
  for (int przerwa = (0); przerwa <= (N - 1); ++przerwa) ile[0][przerwa][1] = 1;
  for (int d = (1); d <= (N - 1); ++d) {
    for (int przerwa = (0); przerwa <= (N - 1); ++przerwa)
      for (int dobra = 0; dobra < (2); ++dobra) {
        int &x = ile[d][przerwa][dobra];
        x = 0;
        {
          x = (x +
               2LL *
                   ile[d - 1][0][dobra || (przerwa != N - 1 && przerwa < k)]) %
              MOD;
        }
        { x = (x + 8LL * ile[d - 1][min(przerwa + 1, N - 1)][dobra]) % MOD; }
      }
  }
  for (int d = (1); d <= (N - 1); ++d) {
    wszystkie_dobre[d] = wszystkie_dobre[d - 1];
    wszystkie_dobre[d] = (wszystkie_dobre[d] + 2LL * ile[d - 1][0][0]) % MOD;
    wszystkie_dobre[d] =
        (wszystkie_dobre[d] + 7LL * ile[d - 1][N - 1][0]) % MOD;
  }
}
int licz(char *txt) {
  int n = strlen(txt);
  int res = wszystkie_dobre[n - 1];
  int dobra = 0;
  int przerwa = N - 1;
  for (int i = 0; i < (n); ++i) {
    int last = i == 0 ? 1 : 0;
    for (int cyfra = txt[i] - '0' - 1; cyfra >= last; cyfra--) {
      int ndobra = dobra;
      int nprzerwa = przerwa;
      if (cyfra == 4 || cyfra == 7) {
        ndobra |= (przerwa != N - 1 && przerwa < k);
        nprzerwa = 0;
      } else
        nprzerwa = min(przerwa + 1, N - 1);
      res = (res + ile[n - i - 1][nprzerwa][ndobra]) % MOD;
    }
    if (txt[i] == '4' || txt[i] == '7') {
      dobra |= (przerwa != N - 1 && przerwa < k);
      przerwa = 0;
    } else
      przerwa = min(przerwa + 1, N - 1);
  }
  return res;
}
char txt[N], txt2[N];
int main() {
  int testy;
  scanf("%d %d", &testy, &k);
  init();
  while (testy--) {
    scanf("%s %s", txt, txt2);
    int res = (licz(txt2) + MOD - licz(txt)) % MOD;
    if (dobra(txt2)) res = (res + 1) % MOD;
    printf("%d\n", res);
  }
  return 0;
}