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;
template <class A, class B>
A convert(B x) {
  stringstream s;
  s << x;
  A r;
  s >> r;
  return r;
}
int len, k;
int dp[1010][1010];
int calc[1010];
const int mod = 1000000007;
string S;
int Add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
int Sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
int Mul(int a, int b) { return ((long long)a * (long long)b) % mod; }
int Rec(int p, int last) {
  if (p == 0) return 0;
  if (last > k) last = k + 1;
  int& res = dp[p][last];
  if (res != -1) return res;
  if (last <= k)
    res = Mul(calc[p - 1], 2);
  else
    res = Mul(Rec(p - 1, 1), 2);
  res = Add(res, Mul(Rec(p - 1, last + 1), 8));
  return res;
}
int Check(string s) {
  int last = -k - 1;
  for (int i = (0), _b(((int)(s).size())); i < _b; ++i) {
    if (s[i] == '4' || s[i] == '7') {
      if (i - last <= k) return 1;
      last = i;
    }
  }
  return 0;
}
int ToInt(int pos) {
  int res = 0;
  for (int i = (pos), _b(((int)(S).size())); i < _b; ++i) {
    res = Mul(res, 10);
    res = Add(res, S[i] - '0');
  }
  return res;
}
int Calc(int pos, int last) {
  if (pos == ((int)(S).size())) return 0;
  int res = 0;
  if (!pos) res = Rec(((int)(S).size()) - 1, k + 1);
  for (int i = (pos == 0), _b(S[pos] - '0'); i < _b; ++i)
    if (i == 4 || i == 7)
      if (pos - last <= k)
        res = Add(res, calc[((int)(S).size()) - pos - 1]);
      else
        res = Add(res, Rec(((int)(S).size()) - pos - 1, 1));
    else
      res = Add(res, Rec(((int)(S).size()) - pos - 1, pos - last + 1));
  if (S[pos] == '4' || S[pos] == '7') {
    if (pos - last <= k)
      res = Add(res, ToInt(pos + 1) + 1);
    else
      res = Add(res, Calc(pos + 1, pos));
  } else
    res = Add(res, Calc(pos + 1, last));
  return res;
}
int Calc(string N) {
  S = N;
  return Calc(0, -k - 1);
}
int Brut(int L, int R) {
  int res = 0;
  for (int i = (L), _b(R + 1); i < _b; ++i)
    res += Check(convert<string, int>(i));
  return res;
}
int main() {
  calc[0] = 1;
  for (int i = (1), _b(1010); i < _b; ++i) calc[i] = Mul(calc[i - 1], 10);
  int tc;
  scanf("%d %d", &tc, &k);
  string l, r;
  memset(dp, -1, sizeof(dp));
  while (tc-- > 0) {
    cin >> l >> r;
    cout << Sub(Calc(r), Sub(Calc(l), Check(l))) << endl;
  }
  return 0;
}