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;
struct debugger {
  template <typename T>
  debugger &operator,(const T &v) {
    cerr << v << "\t";
    return *this;
  }
} dbg;
template <class T>
void setmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void setmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
T Abs(T x) {
  return x > 0 ? x : -x;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
string toString(T n) {
  ostringstream oss;
  oss << n;
  oss.flush();
  return oss.str();
}
long long toInt(string s) {
  long long r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
bool isVowel(char ch) {
  ch = tolower(ch);
  if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
    return true;
  return false;
}
bool isUpper(char c) { return c >= 'A' && c <= 'Z'; }
bool isLower(char c) { return c >= 'a' && c <= 'z'; }
long long Pow(long long B, long long P) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) R = (R * B);
    P /= 2;
    B = (B * B);
  }
  return R;
}
long long BigMod(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return R;
}
void binprint(long long mask, long long n) {
  long long i;
  string s = "";
  do {
    s += (mask % 2 + '0');
    mask /= 2;
  } while (mask);
  reverse(s.begin(), s.end());
  s = string(max(n - (int)s.size(), 0LL), '0') + s;
  for (i = (int)s.size() - n; i < (int)s.size(); i++) printf("%c", s[i]);
  printf("\n");
}
void ASCII_Chart() {
  long long i, j, k;
  printf("ASCII Chart:(30-129)\n");
  for (i = 30; i < 50; i++) {
    for (j = 0; j < 5; j++) {
      k = i + j * 20;
      printf("%3d---> '%c'   ", k, k);
    }
    printf("\n");
  }
}
const long long Mod = 1000000007;
long long mm[1009][1009][2];
int K;
void Add(long long &re, long long val) {
  re += val;
  re %= Mod;
}
long long bm(long long b, int p) {
  if (!p) return 1;
  long long x = bm(b, p / 2);
  x = (x * x) % Mod;
  if (p & 1) x = (x * b) % Mod;
  return x;
}
long long go(int len, int l, int ch) {
  if (!len) return ch;
  long long &re = mm[len][l][ch];
  if (re > -1) return re;
  re = 0;
  int c, nl;
  for (int i = 0; i < 10; i++) {
    c = 0;
    nl = l;
    if (l <= K && (i == 4 || i == 7)) c = 1;
    if (i == 7 || i == 4) nl = 0;
    Add(re, go(len - 1, min(nl + 1, 1001), ch || c));
  }
  return re;
}
char a[1004], b[1004];
long long cal(char txt[], int p, int l, int k, int ch) {
  if (p == l) return 0;
  long long re = 0, v = txt[p] - 48, nk, c;
  for (int i = 0; i <= v; i++) {
    c = 0;
    if (k <= K && (i == 4 || i == 7)) c = 1;
    nk = k;
    if (i == 4 || i == 7) nk = 0;
    if (i == v)
      Add(re, cal(txt, p + 1, l, min(nk + 1, 1001LL), ch || c));
    else
      Add(re, go(l - p - 1, min(nk + 1, 1001LL), ch || c));
  }
  return re;
}
int check(char txt[], int l) {
  int i, lst = -2 * K;
  for (i = 0; i < l; i++) {
    if (txt[i] - 48 == 4 || txt[i] - 48 == 7) {
      if (i - lst <= K) return 1;
      lst = i;
    }
  }
  return 0;
}
int main() {
  int i, j, test, Case = 1, n, la, lb;
  long long A, B;
  while (scanf("%d%d", &n, &K) == 2) {
    memset(mm, -1, sizeof mm);
    for (i = 0; i < n; i++) {
      scanf("%s%s", a, b);
      la = strlen(a);
      lb = strlen(b);
      A = cal(a, 0, la, K + 1, 0);
      B = cal(b, 0, lb, K + 1, 0);
      A = (check(b, lb) + B - A + Mod) % Mod;
      printf("%I64d\n", A);
    }
  }
  return 0;
}