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>
void initf() {}
using namespace std;
const int inf = (1 << 30);
const int mod = 1000000007;
int T, K;
char s1[1004], s2[1004];
int le[1004], ri[1004];
int a[1004];
int n;
int dp[1004][1004];
void sub() {
  int id = -1;
  for (int i = n - 1; i >= 0; --i) {
    if (a[i] != 0) {
      id = i;
      break;
    }
  }
  --a[id];
  for (int i = (id + 1); i <= (n - 1); ++i) {
    a[i] = 9;
  }
}
int getAm() {
  long long cur = 0;
  long long mem = 0;
  for (int i = 0; i < (n); ++i) {
    mem = mem * 10LL + a[i];
    mem %= mod;
  }
  return mem;
}
int rec(int len, int last) {
  if (dp[len][last] != -1) return dp[len][last];
  if (len == 0) {
    return 1;
  }
  dp[len][last] = 0;
  int am = 8;
  long long ret = rec(len - 1, max(last - 1, 0));
  ret *= (long long)am;
  ret %= mod;
  dp[len][last] = (int)ret;
  if (!last) {
    long long ret = rec(len - 1, K);
    ret *= (long long)2;
    ret %= mod;
    dp[len][last] += (int)ret;
    if (dp[len][last] >= mod) {
      dp[len][last] -= mod;
    }
  }
  return dp[len][last];
}
int rec1() {
  int last = 0;
  int ret = 0;
  for (int i = 0; i < (n); ++i) {
    int dig = a[i];
    int start = 0;
    for (int j = (start); j <= (dig - 1); ++j) {
      if (j == 4 || j == 7) {
        if (last != 0) {
          continue;
        } else {
          ret += rec(n - i - 1, K);
          if (ret >= mod) ret -= mod;
        }
      } else {
        ret += rec(n - i - 1, max(last - 1, 0));
        if (ret >= mod) ret -= mod;
      }
    }
    if (a[i] == 4 || a[i] == 7) {
      if (last) {
        return ret;
      } else {
        last = K;
      }
    } else {
      --last;
      if (last < 0) last = 0;
    }
  }
  return (ret + 1) % mod;
}
void solve() {
  scanf("%s %s\n", s1, s2);
  n = strlen(s2);
  for (int i = 0; i < (n); ++i) a[i] = s2[i] - '0';
  int tot = getAm();
  int ans = rec1();
  n = strlen(s1);
  for (int i = 0; i < (n); ++i) a[i] = s1[i] - '0';
  sub();
  int ans2 = rec1();
  int tot2 = getAm();
  ans = ans - ans2;
  if (ans < 0) ans += mod;
  tot = tot - tot2;
  if (tot < 0) tot += mod;
  tot -= ans;
  if (tot < 0) {
    tot += mod;
  }
  printf("%d\n", tot);
}
int main() {
  initf();
  scanf("%d%d", &T, &K);
  memset((dp), (-1), sizeof((dp)));
  while (T--) {
    solve();
  }
  return 0;
}