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.
#include <bits/stdc++.h>
using namespace std;
long long dp[1111][1111][2];
const long long mod = 1000000007;
int lim, len;
char s[1111];
long long getdp(int l, int less, int last, int ok) {
  if (l == -1) return ok;
  long long &ret = dp[l][last][ok];
  if (!less && ret != -1) return ret;
  long long res = 0;
  int u;
  if (!less)
    u = 9;
  else
    u = s[l] - '0';
  if (ok == 1) {
    for (int i = 0; i <= u; i++) {
      int tl = 0;
      res += getdp(l - 1, less && i == u, 0, 1);
      if (res >= mod) res -= mod;
    }
    if (!less) ret = res;
    return res;
  }
  for (int i = 0; i <= u; i++) {
    int tl = 0;
    if (i == 4 || i == 7) {
      if (last != 1003 && last - l <= lim)
        res += getdp(l - 1, less && i == u, l, 1);
      else
        res += getdp(l - 1, less && i == u, l, 0);
    } else
      res += getdp(l - 1, less && i == u, last, 0);
    if (res >= mod) res -= mod;
  }
  if (!less) ret = res;
  return res;
}
long gao(char *x) {
  strcpy(s, x);
  len = strlen(s);
  reverse(s, s + len);
  return getdp(len - 1, 1, 1003, 0);
}
long long test(char *x) {
  int aa[1111], nn = 0, lll = strlen(x), i;
  for (i = 0; i < lll; i++)
    if (x[i] == '4' || x[i] == '7') aa[nn++] = i;
  for (i = 0; i < nn - 1; i++) {
    if (aa[i + 1] - aa[i] <= lim) return 1;
  }
  return 0;
}
void run() {
  int cas;
  scanf("%d%d", &cas, &lim);
  char l[1111], r[1111];
  while (cas--) {
    scanf("%s%s", l, r);
    long long ans = gao(r) - gao(l) + test(l);
    ans = (ans % mod + mod) % mod;
    cout << ans << endl;
  }
}
int main() {
  memset(dp, -1, sizeof(dp));
  run();
  return 0;
}
