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;
using lli = long long;
using lld = long double;
using ulli = unsigned long long int;
using pll = pair<lli, lli>;
using ttt = pair<lli, pll>;
using vttt = vector<ttt>;
using vll = vector<pll>;
using vl = vector<lli>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using cd = complex<lld>;
const double PI = acos(-1);
inline lli mpow(lli a, lli b, lli m = 1000000007) {
  lli ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    a = (a * a) % m;
    b /= 2;
  }
  return ans;
}
std::vector<vl> dp2(1010, vl(1010));
vl dp(1010), tdp(1010), po(1010);
void __prec(int k) {
  lli temp = 0;
  for (int i = 0; i < 1010; i++) po[i] = mpow(8, i);
  dp[0] = 1;
  for (int i = 1; i < 1010; i++) {
    for (int j = 0; j < max(1, i - k); j++) {
      temp = (2LL * po[i - j - 1] * dp[j]) % 1000000007;
      dp[i] = (dp[i] + temp) % 1000000007;
    }
  }
  for (int i = 1010 - 1; i >= 0; i--) {
    for (int j = 0; j < i; j++) {
      temp = (po[i - j] * dp[j]) % 1000000007;
      dp[i] = (dp[i] + temp) % 1000000007;
    }
  }
  for (int i = 0; i < 1010; i++)
    dp[i] = (mpow(10, i) - dp[i] + 1000000007) % 1000000007;
  for (int i = 1; i < 1010; i++)
    dp2[1][i] = (2ll * mpow(10, i - 1)) % 1000000007;
  for (int i = 2; i < 1010; i++) {
    dp2[i][i] = ((dp2[i - 1][i - 1] * 8LL) + dp2[1][i]) % 1000000007;
    for (int j = i + 1; j < 1010; j++)
      dp2[i][j] = (dp2[i][j - 1] * 10LL) % 1000000007;
  }
}
lli calc(string s, int k) {
  int n = ((lli)(s).size());
  int ind = -1, coun = 0, tind = -1, tcoun = 0;
  bool fl = 0, tfl = 0;
  lli ans = 0, temp;
  for (int i = 0; i < n; i++) {
    int cur = s[i] - '0';
    tind = ind;
    tcoun = coun;
    tfl = fl;
    for (int bit = 0; bit < cur; bit++) {
      if (bit == 4 || bit == 7) {
        tind = i;
        tcoun = coun + 1;
        if (ind >= 0 && tind - ind <= k) tfl = 1;
      }
      if (tfl)
        ans += mpow(10, n - i - 1);
      else {
        if (tind >= 0) {
          if (tind + k + 1 < n) {
            if (tind + k + 1 > i + 1) {
              temp = (po[tind + k - i] * dp[n - tind - k - 1]) % 1000000007;
              ans += temp;
              ans += dp2[tind + k - i][n - i - 1];
            } else
              ans += dp[n - i - 1];
          } else
            ans += dp2[n - i - 1][n - i - 1];
        } else
          ans += dp[n - i - 1];
      }
      ans %= 1000000007;
      tind = ind;
      tcoun = coun;
      tfl = fl;
    }
    if (cur == 4 || cur == 7) {
      if (ind >= 0 && i - ind <= k) fl = 1;
      ind = i;
      coun++;
    }
  }
  if (fl) ans = (ans + 1) % 1000000007;
  return ans;
}
bool check(string& s, int k) {
  int ind = -1000000007;
  for (int i = 0; i < ((lli)(s).size()); i++) {
    if (s[i] == '4' || s[i] == '7') {
      if (i - ind <= k) return 1;
      ind = i;
    }
  }
  return 0;
}
int tejas_919(int kkkk) {
  lli n, m, k, q, u, v, temp = 0, ans = 0;
  cin >> q >> k;
  __prec(k);
  while (q--) {
    string s;
    cin >> s;
    if (check(s, k))
      ans = 1;
    else
      ans = 0;
    ans -= calc(s, k);
    cin >> s;
    ans += calc(s, k);
    ans = ((ans % 1000000007) + 1000000007) % 1000000007;
    cout << ans << '\n';
  }
  return 0;
}
signed main() {
  if (!0) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  }
  cout << fixed << setprecision(10);
  int t = 1;
  for (int i = 0; i < t; i++) {
    tejas_919(i + 1);
  }
  {};
  if (0) system("pause");
}