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 long long MOD = 1000000007;
long long dp[1001][1001][2];
long long s[1001];
long long pot10[1001], pot8[1001];
int t, k;
bool Ok(string a) {
  int ost = -1;
  for (int i = 0; i < a.size(); ++i) {
    if ((a[i] == '4' || a[i] == '7') && ost != -1 && i - ost <= k) return true;
    if (a[i] == '4' || a[i] == '7') ost = i;
  }
  return false;
}
long long Ile(string A) {
  string X = A;
  int n = A.size();
  int ost = -1;
  bool pref_ok = false;
  long long odp = 0;
  for (int i = 0; i < n; ++i) {
    for (char c = '0'; c < A[i]; ++c) {
      bool c_ok = ((c == '4' || c == '7') ? true : false);
      X[i] = c;
      int suf = n - i - 1;
      bool jest_w_pref = false;
      if (pref_ok || (ost != -1 && c_ok && i - ost <= k)) jest_w_pref = true;
      if (jest_w_pref)
        odp = (odp + pot10[suf]) % MOD;
      else {
        if (ost != -1 || c_ok) {
          int ost_db = (c_ok ? i : ost);
          int kon = min(ost_db + k, n - 1);
          int pref = kon - i;
          if (pref > 0) {
            long long il_pref = pot10[pref] - pot8[pref];
            if (il_pref < 0) il_pref += MOD;
            odp = (odp + il_pref * pot10[suf - pref]) % MOD;
            il_pref = pot8[pref];
            odp = (odp + il_pref * s[suf - pref]) % MOD;
          } else
            odp = (odp + s[suf]) % MOD;
        } else
          odp = (odp + s[suf]) % MOD;
      }
    }
    X[i] = A[i];
    if (ost != -1 && (X[i] == '4' || X[i] == '7') && i - ost <= k)
      pref_ok = true;
    if (X[i] == '4' || X[i] == '7') ost = i;
  }
  if (Ok(A)) odp = (odp + 1) % MOD;
  return odp;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> t >> k;
  pot10[0] = pot8[0] = 1;
  for (int i = 1; i < 1001; ++i) {
    pot10[i] = (pot10[i - 1] * 10) % MOD;
    pot8[i] = (pot8[i - 1] * 8) % MOD;
  }
  for (int i = 0; i < 1001; ++i)
    for (int j = 0; j < 1001; ++j)
      for (int k = 0; k < 2; ++k) dp[i][j][k] = 0;
  for (int i = 0; i < 1001; ++i) s[i] = 0;
  dp[1][0][0] = 8;
  dp[1][1][0] = 2;
  for (int i = 1; i < 1000; ++i) {
    for (int j = 0; j <= i; ++j) {
      for (int l = 0; l < 2; ++l) {
        for (int c = 0; c <= 9; ++c) {
          int nowy_i = i + 1;
          int nowy_j = ((c == 4 || c == 7) ? i + 1 : j);
          int nowy_l =
              ((l == 1 || ((c == 4 || c == 7) && j != 0 && i + 1 - j <= k))
                   ? 1
                   : 0);
          dp[nowy_i][nowy_j][nowy_l] =
              (dp[nowy_i][nowy_j][nowy_l] + dp[i][j][l]) % MOD;
          if (nowy_l == 1) s[nowy_i] = (s[nowy_i] + dp[i][j][l]) % MOD;
        }
      }
    }
  }
  for (int i = 0; i < t; ++i) {
    string a, b;
    cin >> a >> b;
    long long odp = Ile(b) - Ile(a);
    if (Ok(a)) ++odp;
    if (odp < 0) odp += MOD;
    odp %= MOD;
    cout << odp << endl;
  }
  return 0;
}