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 inf = ~0U >> 1;
const long long LINF = ~(((long long)0x1) << 63) / 2;
template <class T>
bool get_max(T &a, T &b) {
  return b > a ? a = b, 1 : 0;
}
template <class T>
bool get_min(T &a, T &b) {
  return b < a ? a = b, 1 : 0;
}
const long long MOD = 1000000007LL;
int t, k;
string lstr, rstr;
char A[1005], B[1005];
long long dp[1105][1105][3][2];
int digit[1105];
int nlim = 1100;
long long dfs(int pos, int luck_pos, int less, int have) {
  if (pos == 0) return have;
  if (!(less == 1) && dp[pos][luck_pos][less][have] != -1)
    return dp[pos][luck_pos][less][have];
  long long ans = 0;
  if (less == 2) {
    ans = (ans + dfs(pos - 1, nlim, 2, 0)) % MOD;
    for (int i = 1; i <= 9; i++) {
      if (i == 4 || i == 7)
        ans = (ans + dfs(pos - 1, pos - 1, 0, 0)) % MOD;
      else
        ans = (ans + dfs(pos - 1, nlim, 0, 0)) % MOD;
    }
  } else {
    int lim = (less ? digit[pos - 1] : 9);
    if (have) {
      for (int i = 0; i <= lim; i++) {
        ans += dfs(pos - 1, 0, less && i == lim, 1);
        ans %= MOD;
      }
      if (!(less == 1)) dp[pos][luck_pos][less][have] = ans;
      return ans;
    }
    for (int i = 0; i <= lim; i++) {
      if (i == 4 || i == 7) {
        if (luck_pos != nlim && luck_pos - pos + 1 <= k) {
          ans += dfs(pos - 1, pos - 1, less && i == lim, 1);
        } else {
          ans += dfs(pos - 1, pos - 1, less && i == lim, 0);
        }
      } else {
        ans += dfs(pos - 1, luck_pos, less && i == lim, have);
      }
      ans %= MOD;
    }
  }
  ans %= MOD;
  if (!(less == 1)) dp[pos][luck_pos][less][have] = ans;
  return ans;
}
long long solve(string str) {
  int n = str.size();
  for (int i = n - 1; i >= 0; i--) {
    digit[n - 1 - i] = str[i] - '0';
  }
  long long ans = 0;
  ans += dfs(n - 1, nlim, 2, 0);
  ans %= MOD;
  for (int i = 1; i <= digit[n - 1]; i++) {
    if (i != digit[n - 1]) {
      if (i == 4 || i == 7) {
        ans += dfs(n - 1, n - 1, 0, 0);
      } else {
        ans += dfs(n - 1, nlim, 0, 0);
      }
    } else {
      if (i == 4 || i == 7) {
        ans += dfs(n - 1, n - 1, 1, 0);
      } else {
        ans += dfs(n - 1, nlim, 1, 0);
      }
    }
    ans %= MOD;
  }
  return ans % MOD;
}
int main() {
  scanf("%d%d", &t, &k);
  memset(dp, -1, sizeof(dp));
  while (t--) {
    cin >> A >> B;
    for (int i = strlen(A) - 1; i >= 0; i--) {
      if (A[i] == '0')
        A[i] = '9';
      else {
        A[i]--;
        break;
      }
    }
    char *p = A;
    if (*p == '0' && *(p + 1) != 0) p++;
    long long ans1 = solve(p);
    long long ans2 = solve(B);
    ans1 %= MOD;
    ans2 %= MOD;
    long long re = (ans2 - ans1 + MOD) % MOD;
    cout << re << endl;
  }
  return 0;
}