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:65777216")
using namespace std;
const int mod = 1000000007;
int ten[1111];
int qp(int __un, int st) {
  if (ten[0] == -1) {
    ten[0] = 1;
    for (int i(1); i < (1111); i++) {
      ten[i] = (10ll * ten[i - 1]) % mod;
    }
  }
  return ten[st];
}
int t, k;
char s1[1111];
char s2[1111];
int d[1111][1111];
int go(int n, int w) {
  if (n == 0) return 0;
  w = min(w, k);
  if (d[n][w] != -1) return d[n][w];
  long long res = 0;
  res += 8ll * go(n - 1, w + 1);
  if (w + 1 <= k)
    res += 2 * qp(10, n - 1);
  else
    res += 2 * go(n - 1, 0);
  res %= mod;
  return d[n][w] = res;
}
int solve(char *s) {
  int res = 0;
  int n = strlen(s);
  int last = -1000000;
  bool calcf = 1;
  for (int i(0); i < (n); i++) {
    for (int d(0); d < (s[i] - '0'); d++) {
      if ((d == 7 || d == 4) && i - last <= k) {
        res += qp(10, n - 1 - i);
        if (res >= mod) res -= mod;
      } else if ((d == 7 || d == 4)) {
        res += go(n - i - 1, 0);
        if (res >= mod) res -= mod;
      } else {
        res += go(n - i - 1, i - last);
        if (res >= mod) res -= mod;
      }
    }
    if (s[i] == '4' || s[i] == '7') {
      if (i - last <= k) {
        long long t = 0;
        for (int j(i + 1); j < (n); j++) {
          t = 10 * t + s[j] - '0';
          t %= mod;
        }
        t++;
        res += t;
        res %= mod;
        return res;
      }
      last = i;
    }
  }
  return res;
}
char TT[1111];
bool good(char *s) {
  int n = strlen(s);
  int last = -1000000;
  for (int i(0); i < (n); i++)
    if (s[i] == '4' || s[i] == '7') {
      if (i - last <= k) return 1;
      last = i;
    }
  return 0;
}
int stupid() {
  string _s1(s1);
  string _s2(s2);
  stringstream ss1(_s1);
  stringstream ss2(_s2);
  int l, r;
  ss1 >> l;
  ss2 >> r;
  int res = 0;
  for (int i = l; i <= r; i++) {
    stringstream ss;
    ss << i;
    string w = ss.str();
    for (int j(0); j < (w.size()); j++) TT[j] = w[j];
    TT[w.size()] = 0;
    if (good(TT)) res++;
  }
  return res;
}
int main() {
  memset(d, -1, sizeof(d));
  memset(ten, -1, sizeof(ten));
  cin >> t >> k;
  if (0) {
    for (int i(445); i < (1000); i++) {
      for (int j(max(1, i - 100)); j < (i + 1); j++) {
        stringstream ss1, ss2;
        ss1 << j;
        ss2 << i;
        string _s1 = ss1.str();
        string _s2 = ss2.str();
        for (int k(0); k < (_s1.size()); k++) s1[k] = _s1[k];
        s1[_s1.size()] = 0;
        for (int k(0); k < (_s2.size()); k++) s2[k] = _s2[k];
        s2[_s2.size()] = 0;
        int res = solve(s2);
        res -= solve(s1);
        if (good(s1)) res++;
        if (res >= mod) res -= mod;
        if (res < 0) res += mod;
        if (res != stupid()) puts("ok!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
      }
      cout << i << endl;
    }
    puts("DONE!");
  }
  for (int i(0); i < (t); i++) {
    scanf(" %s %s", s1, s2);
    int res = solve(s2);
    res -= solve(s1);
    if (good(s1)) res++;
    if (res >= mod) res -= mod;
    if (res < 0) res += mod;
    cout << res << endl;
  }
  return 0;
}