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 base = 1000000000 + 7;
const int Lucky[10] = {0, 0, 0, 0, 1, 0, 0, 1, 0, 0};
int t, k;
int n;
int F[1010][1010][2];
int s[1010][1010], a[1010];
int C[1010], tot[1010];
int work(string S) {
  n = S.size();
  for (int i = 1; i <= n; i++) a[i] = S[i - 1] - 48;
  int cur = k + 1, flag = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int next = 0; next < a[i]; next++) {
      int Cur = min(cur + 1, k + 1), Flag = flag;
      if (Lucky[next]) {
        Cur = 0;
        if (cur + 1 <= k) Flag = 1;
      }
      if (Flag)
        ans += C[n - i], ans %= base;
      else {
        ans += tot[n - i], ans %= base;
        if (k - Cur - 1 >= 0) ans += s[n - i][k - Cur - 1], ans %= base;
      }
    }
    cur++;
    if (Lucky[a[i]]) {
      if (cur <= k) flag = 1;
      cur = 0;
    }
  }
  if (flag) ans++, ans %= base;
  return ans;
}
int check(string s) {
  int cur = k + 1, flag = 0;
  for (int i = 0; i < s.size(); i++) {
    cur++;
    if (Lucky[s[i] - 48]) {
      if (cur <= k) flag = 1;
      cur = 0;
    }
  }
  return flag;
}
int main() {
  cin >> t >> k;
  C[0] = 1;
  for (int i = 1; i <= 1000; i++)
    C[i] = (int)((long long)C[i - 1] * 10LL % (long long)base);
  memset(F, 0, sizeof(F));
  F[0][k + 1][0] = 1;
  for (int i = 0; i < 1000; i++)
    for (int j = 0; j <= k + 1; j++)
      for (int cur = 0; cur < 2; cur++)
        if (F[i][j][cur])
          for (int next = 0; next < 10; next++) {
            int nJ = min(j + 1, k + 1), nCur = cur;
            if (Lucky[next]) {
              nJ = 0;
              if (j + 1 <= k) nCur = 1;
            }
            F[i + 1][nJ][nCur] += F[i][j][cur];
            F[i + 1][nJ][nCur] %= base;
          }
  tot[0] = 0;
  for (int i = 1; i <= 1000; i++)
    for (int j = 0; j <= k + 1; j++) tot[i] += F[i][j][1], tot[i] %= base;
  memset(s, 0, sizeof(s));
  for (int i = 1; i <= 1000; i++) {
    s[i][0] = F[i][0][0] % base;
    for (int j = 1; j <= k + 1; j++)
      s[i][j] = (s[i][j - 1] + F[i][j][0]) % base;
  }
  for (int i = 1; i <= t; i++) {
    string s1, s2;
    cin >> s1 >> s2;
    int ans = work(s2) - work(s1);
    ans += base;
    ans %= base;
    if (check(s1)) ans++, ans %= base;
    cout << ans << endl;
  }
  return 0;
}