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 mod = 1000000007;
class point {
 public:
  int id, val;
};
bool operator<(const point &a, const point &b) {
  if (a.val < b.val) return true;
  return false;
}
int t, k, i, j, p, ans;
int dp[1002][1002][2];
string s1, s2;
string dec(string s) {
  string ans = "";
  int i;
  i = s.length() - 1;
  while (s[i] == '0') {
    i--;
    ans = ans + '9';
  }
  if ((s[i] - 1 > '0') || (i > 0)) ans = char(s[i] - 1) + ans;
  for (i = i - 1; i >= 0; i--) ans = s[i] + ans;
  if (ans.length() == 0) ans = "0";
  return ans;
}
int solve(string s) {
  if (s == "0") return 0;
  int i, j, last = -1;
  int ans = 0;
  int t = 0;
  for (i = 0; i < s.length(); i++) {
    for (j = '0'; j < s[i]; j++)
      if ((j == '4') || (j == '7')) {
        if ((last > -1) && (i - last <= k))
          ans = ((long long)ans + dp[s.length() - 1 - i][i - last][1]) % mod;
        else
          ans = ((long long)ans + dp[s.length() - 1 - i][1][t]) % mod;
      } else if (last == -1)
        ans = ((long long)ans + dp[s.length() - 1 - i][0][t]) % mod;
      else
        ans = ((long long)ans + dp[s.length() - 1 - i][i + 1 - last][t]) % mod;
    if ((s[i] == '4') || (s[i] == '7')) {
      if ((last > -1) && (i - last <= k)) t = 1;
      last = i;
    }
  }
  if (t == 1) ans = (ans + 1) % mod;
  return ans;
}
int main() {
  cin >> t >> k;
  for (i = 0; i <= 1000; i++)
    for (j = 0; j <= 1000 - i; j++)
      for (p = 0; p <= 1; p++) {
        ans = 0;
        if (i == 0) {
          ans = p;
        } else if (p == 1) {
          ans = ((long long)10 * dp[i - 1][j][p]) % mod;
        } else if (j == 0) {
          ans = ((long long)2 * dp[i - 1][1][0]) % mod;
          ans = (ans + (long long)8 * dp[i - 1][0][0]) % mod;
        } else {
          if (j <= k)
            ans = ((long long)2 * dp[i - 1][j][1]) % mod;
          else
            ans = ((long long)2 * dp[i - 1][1][0]) % mod;
          ans = (ans + (long long)8 * dp[i - 1][j + 1][0]) % mod;
        }
        dp[i][j][p] = ans;
      }
  for (i = 1; i <= t; i++) {
    cin >> s1 >> s2;
    s1 = dec(s1);
    cout << ((long long)solve(s2) - solve(s1) + mod) % mod << endl;
  }
  return 0;
}