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 max_n = 1011, mod = 1000000007;
int t, k;
long long pw[max_n], pw2[max_n];
int dp[max_n], sumdp[max_n], sums[max_n][max_n];
char ll[max_n], rr[max_n];
string l, r;
int sum_dp(int r) { return sumdp[r]; }
long long sum(int st, int cnt) {
  if (cnt < 0 || st < 0) {
    return 0;
  }
  return sums[st][cnt];
}
void get_all_sum() {
  for (int st = 0; st < max_n; ++st) {
    sums[st][1] = (2 * pw[st] * pw2[0]) % mod;
    for (int cnt = 2; cnt <= st + 1; ++cnt) {
      sums[st][cnt] =
          (sums[st][cnt - 1] + 2 * pw[st - cnt + 1] * pw2[cnt - 1]) % mod;
    }
  }
}
void get_dp() {
  pw[0] = 1;
  pw2[0] = 1;
  for (int i = 1; i < max_n; ++i) {
    pw[i] = (pw[i - 1] * 10) % mod;
    pw2[i] = (pw2[i - 1] * 8) % mod;
  }
  dp[0] = dp[1] = 0;
  get_all_sum();
  for (int len = 2; len < max_n; ++len) {
    for (int i = 1; i <= len; ++i) {
      long long x = 1;
      int poz = i - k;
      if (poz > 1) {
        x = (x * pw2[k]) % mod;
        long long y = ((9 * pw[poz - 2] - dp[poz - 1]) % mod + mod) % mod;
        x = (x * y) % mod;
      } else {
        if (i != 1) {
          x = (x * pw2[i - 2] * 7) % mod;
        }
      }
      dp[len] =
          (dp[len] + (2 * x * sum(len - i - 1, min(len, k + i) - i)) % mod) %
          mod;
    }
    sumdp[len] = (sumdp[len - 1] + dp[len]) % mod;
  }
}
bool ok(string s) {
  int last = -11111;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '4' || s[i] == '7') {
      if (i - last <= k) {
        return true;
      }
      last = i;
    }
  }
  return false;
}
bool happy(int x) { return x == 4 || x == 7; }
long long fun(string r) {
  int res = sumdp[r.length() - 1];
  int last = -111111;
  for (int i = 0; i < r.length(); ++i) {
    int st = 0, fin = r[i] - '0';
    if (i == 0) {
      st = 1;
    }
    for (int j = st; j < fin; ++j) {
      if (happy(j)) {
        if (i - last <= k) {
          res = (res + pw[r.length() - i - 1]) % mod;
        } else {
          res = (res +
                 sum(r.length() - i - 2, min((int)r.length() - 1, i + k) - i)) %
                mod;
          int poz = i + k + 1;
          if (poz < r.length()) {
            long long x = (pw2[k] * sum_dp(r.length() - poz)) % mod;
            res = (res + x) % mod;
          }
        }
      } else {
        if (last < 0) {
          res = (res + sum_dp(r.length() - i - 1)) % mod;
        } else {
          res = (res + sum(r.length() - i - 2,
                           min((int)r.length() - 1, k + last) - i)) %
                mod;
          int poz = max(i + 1, last + k + 1);
          if (poz < r.length()) {
            long long x = (pw2[poz - i - 1] * sum_dp(r.length() - poz)) % mod;
            res = (res + x) % mod;
          }
        }
      }
    }
    if (happy(fin)) {
      if (i - last <= k) {
        res = (res + 1) % mod;
        long long x = 0;
        for (int j = i + 1; j < r.length(); ++j) {
          x = (x * 10 + r[j] - '0') % mod;
        }
        res = (res + x) % mod;
        return res;
      }
      last = i;
    }
  }
  return res;
}
int main() {
  cin >> t >> k;
  get_dp();
  while (t--) {
    scanf("%s%s", ll, rr);
    l = ll;
    r = rr;
    long long x = fun(r);
    long long y = fun(l);
    long long ans = ((x - y) % mod + mod) % mod;
    if (ok(l)) {
      ans = (ans + 1) % mod;
    }
    cout << ans << endl;
  }
  return 0;
}