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>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-8;
const long double PI = 3.1415926535897932384626433832795;
const int MAXN = 1100;
const long long MOD = INF + 7;
const string Z = "47";
int k, n, sum[MAXN], good[MAXN];
char a[MAXN];
long long d[MAXN][2], p8[MAXN], dd[MAXN];
inline int getSum(int l, int r) {
  if (l > r) return 0;
  int ans = sum[r];
  if (l > 0) ans -= sum[l - 1];
  return ans;
}
long long brute(int v, int len, int now, int must) {
  if (now == 0 && must == 0) return p8[len];
  if (now == 1 && must == 1) return (getSum(v, v + len - 1) == 0) ? 1 : 0;
  long long &ans = dd[v];
  if (ans != -1) return ans;
  ans = 0;
  for (int l = 0; l < (int)(len); l++) {
    long long cur =
        (brute(v, l, 1, 1) * brute(v + l + 1, len - l - 1, 0, 0)) % MOD;
    ans = ans + (cur * good[a[v + l] - '0']) % MOD;
  }
  ans %= MOD;
  return ans;
}
long long get(int pos, int eq) {
  if (pos == n) return 1;
  long long &ans = d[pos][eq];
  if (ans != -1) return ans;
  ans = 0;
  {
    for (int i = 0; i < (int)(10); i++) {
      if (i == 4 || i == 7) continue;
      if (eq == 1 && i + '0' > a[pos]) continue;
      int neq = eq;
      if (i + '0' < a[pos]) neq = 0;
      ans += get(pos + 1, neq);
    }
    ans %= MOD;
  }
  for (int i = 0; i < (int)(2); i++)
    if (eq == 0 || Z[i] <= a[pos]) {
      int neq = eq, u = min(n, pos + k + 1);
      if (Z[i] < a[pos]) neq = 0;
      for (int eqq = 0; eqq < (int)(neq + 1); eqq++)
        ans += brute(pos + 1, u - pos - 1, neq, eqq) * get(u, eqq);
      ans %= MOD;
    }
  ans %= MOD;
  return ans;
}
long long get() {
  n = (int)strlen(a);
  long long p = 1, cur = 0;
  for (int i = (int)(n)-1; i >= 0; i--) {
    cur = (cur + p * (a[i] - '0')) % MOD;
    p = (p * 10) % MOD;
  }
  for (int i = 0; i < (int)(n); i++) {
    sum[i] = (a[i] == '4' || a[i] == '7') ? 1 : 0;
    if (i > 0) sum[i] += sum[i - 1];
  }
  memset(d, 255, sizeof d);
  memset(dd, 255, sizeof dd);
  return (cur - get(0, 1) + 1 + MOD) % MOD;
}
long long check() {
  n = (int)strlen(a);
  int last = INF;
  for (int i = (int)(n)-1; i >= 0; i--)
    if (a[i] == '4' || a[i] == '7') {
      if (last - i <= k) return 1;
      last = i;
    }
  return 0;
}
void solve() {
  scanf("%s", a);
  long long l = get() - check();
  scanf("%s", a);
  long long r = get();
  cout << (r - l + MOD) % MOD << endl;
}
void gen() {
  k = 1;
  int cur = 0;
  for (int i = 0; i < (int)(INF); i++) {
    sprintf(a, "%d", i + 1);
    if (check()) cur++;
    if (cur != get()) throw;
    if (i % 10000 == 0) cerr << i << endl;
  }
}
int main() {
  for (int i = 1; i <= 9; i++) {
    good[i] = good[i - 1];
    if (i != 5 && i != 8) good[i]++;
  }
  for (int i = 0; i < (int)(MAXN); i++)
    p8[i] = (i == 0) ? 1 : ((p8[i - 1] * 8) % MOD);
  int tests;
  cin >> tests >> k;
  for (int test = 0; test < (int)(tests); test++) solve();
  return 0;
}