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 GCC optimize("O3")
using namespace std;
inline long long getint() {
  long long _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
inline long long add(long long _x, long long _y,
                     long long _mod = 1000000007LL) {
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline long long sub(long long _x, long long _y,
                     long long _mod = 1000000007LL) {
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline long long mul(long long _x, long long _y,
                     long long _mod = 1000000007LL) {
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
long long mypow(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 1LL;
  long long _ret = mypow(mul(_a, _a, _mod), _x >> 1, _mod);
  if (_x & 1) _ret = mul(_ret, _a, _mod);
  return _ret;
}
long long mymul(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 0LL;
  long long _ret = mymul(add(_a, _a, _mod), _x >> 1, _mod);
  if (_x & 1) _ret = add(_ret, _a, _mod);
  return _ret;
}
inline bool equal(double _x, double _y) {
  return _x > _y - 1e-9 && _x < _y + 1e-9;
}
int __ = 1, _cs;
int t, k, ten[1021];
int dp[1021][1021][2], ok[1021];
bool lucky(int d) { return d == 4 or d == 7; }
void build() {
  ten[0] = 1;
  for (int i = 1; i < 1021; i++) ten[i] = mul(ten[i - 1], 10);
  dp[0][0][0] = 1;
  for (int i = 1; i < 1021; i++) {
    for (int j = 0; j < i; j++)
      for (int g = 0; g < 2; g++) {
        if (dp[i - 1][j][g] == 0) continue;
        for (int cur = 0; cur < 10; cur++) {
          int nj = j;
          int ng = g;
          if (j and lucky(cur) and i - j <= k) ng = 1;
          if (lucky(cur)) nj = i;
          dp[i][nj][ng] = add(dp[i][nj][ng], dp[i - 1][j][g]);
        }
      }
    for (int j = 0; j <= i; j++) ok[i] = add(ok[i], dp[i][j][1]);
  }
  for (int i = 1; i < 1021; i++)
    for (int j = i; j >= 0; j--)
      dp[i][j][0] = add(dp[i][j][0], dp[i][j + 1][0]);
}
void init() {
  t = getint();
  k = getint();
}
char c[1021];
bool good() {
  int len = strlen(c);
  int pre = -1;
  for (int i = 0; i < len; i++)
    if (lucky(c[i] - '0')) {
      if (pre != -1 and i - pre <= k) return true;
      pre = i;
    }
  return false;
}
int tans;
void go(int now, int pre, int gt) {
  if (now < 1) {
    if (gt) tans = add(tans, 1);
    return;
  }
  int vl = c[now - 1] - '0';
  for (int i = 0; i < vl; i++) {
    if (gt)
      tans = add(tans, ten[now - 1]);
    else if (lucky(i)) {
      if (pre != -1 and pre - now <= k)
        tans = add(tans, ten[now - 1]);
      else {
        tans = add(tans, ok[now - 1]);
        int mst = now - k;
        tans = add(tans, dp[now - 1][max(1, mst)][0]);
      }
    } else {
      tans = add(tans, ok[now - 1]);
      if (pre != -1) {
        int mst = pre - k;
        tans = add(tans, dp[now - 1][max(1, mst)][0]);
      }
    }
  }
  if (lucky(vl)) {
    if (pre != -1 and pre - now <= k) gt = 1;
    pre = now;
  }
  go(now - 1, pre, gt);
}
int cal() {
  int bt = strlen(c);
  for (int i = 0, j = bt - 1; i < j; i++, j--) swap(c[i], c[j]);
  tans = 0;
  go(bt, -1, 0);
  return tans;
}
void solve() {
  build();
  while (t--) {
    scanf("%s", c);
    int ans = sub(0, cal());
    if (good()) ans = add(ans, 1);
    scanf("%s", c);
    ans = add(ans, cal());
    printf("%d\n", ans);
  }
}
int main() {
  while (__--) {
    init();
    solve();
  }
}