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;
long tests, k, dp[1050][1050][3], nend, nwas, luck[20000];
long pw[20000];
string st1, st2;
void add(long &a, long &b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
bool check(string st) {
  long l = -100000;
  for (int i = 0; i < st.size(); i++) {
    if (st[i] == '4' || st[i] == '7') {
      if (i - k <= l) return 1;
      l = i;
    }
  }
  return 0;
}
long solve(string st) {
  long ans = 0;
  if (check(st)) ++ans;
  long lnice = -1;
  long isgood = 0;
  for (int i = 0; i < st.size(); i++) {
    for (int j = 0; j + 48 < st[i]; j++) {
      long tg = isgood;
      long tl = lnice;
      if (j == 4 || j == 7) {
        if (lnice >= 0 && lnice + k >= i) tg = 1;
        tl = i;
      }
      if (i + 1 == st.size()) {
        long one = 1;
        if (tg) add(ans, one);
      } else if (tg == 1) {
        add(ans, pw[st.size() - i - 1]);
      } else if (tl == -1 || tl + k <= i) {
        add(ans, luck[st.size() - i - 1]);
      } else {
        add(ans, luck[st.size() - i - 1]);
        long aps = k - (i - tl);
        if (aps >= (st.size() - i)) aps = st.size() - i - 1;
        add(ans, dp[st.size() - i - 1][st.size() - i - aps][0]);
      }
    }
    if (st[i] == '4' || st[i] == '7')
      if (lnice >= 0 && lnice + k >= i) isgood = 1;
    if (st[i] == '4' || st[i] == '7') lnice = i;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> tests;
  cin >> k;
  dp[0][0][0] = 1;
  for (int i = 0; i <= 1000; i++)
    for (int j = 0; j <= i; j++)
      for (int was = 0; was <= 1; was++)
        for (int ad = 0; ad <= 9; ad++) {
          nend = j;
          nwas = was;
          if (ad == 4 || ad == 7) nend = i + 1;
          if (j > 0 && nend == i + 1 && nend - j <= k) nwas = 1;
          add(dp[i + 1][nend][nwas], dp[i][j][was]);
        }
  for (int i = 0; i <= 1000; i++)
    for (int j = 0; j <= i; j++) add(luck[i], dp[i][j][1]);
  for (int i = 0; i <= 1000; i++)
    for (int j = i; j > 0; j--) add(dp[i][j][0], dp[i][j + 1][0]);
  pw[0] = 1;
  for (int i = 1; i <= 1000; i++) pw[i] = (pw[i - 1] * 1ll * 10) % 1000000007;
  for (; tests; --tests) {
    cin >> st1 >> st2;
    long res = solve(st2);
    res -= solve(st1);
    if (check(st1)) ++res;
    if (res >= 1000000007) res -= 1000000007;
    if (res < 0) res += 1000000007;
    cout << res << endl;
  }
  cin.get();
  cin.get();
  return 0;
}