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;
int countbit(int n) { return (n == 0) ? 0 : (1 + countbit(n & (n - 1))); }
int lowbit(int n) { return (n ^ (n - 1)) & n; }
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
void checkmax(T &a, T b) {
  if (b > a) a = b;
}
const int MOD = 1000000007;
int k;
int f[1005][1005];
int n;
int a[1005];
char buffer[1005];
int add(int a, int b) {
  int c = a + b;
  if (c >= MOD) c -= MOD;
  return c;
}
int mul(int a, int b) { return (int)((long long)a * b % MOD); }
int del(int a, int b) {
  int c = a - b;
  if (c < 0) c += MOD;
  return c;
}
void readin() {
  scanf("%s", buffer);
  memset(a, 0, sizeof(a));
  n = strlen(buffer);
  for (int i = 0; i < n; i++) a[i] = buffer[n - 1 - i] - '0';
}
void addone() {
  a[0]++;
  n++;
  for (int p = 0; a[p] == 10; p++) a[p] = 0, a[p + 1]++;
  for (; a[n - 1] == 0; n--)
    ;
}
void addto(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
int calcf(int d, int p) {
  if (d == 0) return 1;
  if (p > k) p = k;
  int &ret = f[d][p];
  if (ret >= 0) return ret;
  ret = mul(calcf(d - 1, p + 1), 8);
  if (p >= k) addto(ret, mul(calcf(d - 1, 0), 2));
  return ret;
}
int calcg(int d) {
  if (d == 0) return 1;
  return add(mul(calcf(d - 1, 100000000), 7), mul(calcf(d - 1, 0), 2));
}
int solve() {
  for (; a[n - 1] == 0; n--)
    ;
  int R = 0;
  for (int i = 1; i < n; i++) addto(R, calcg(i));
  int last = 100000000;
  for (int i = n - 1; i >= 0; i--) {
    for (int b = (int)(i == n - 1); b < a[i]; b++) {
      if ((b == 4 || b == 7) && last - i <= k) continue;
      addto(R, calcf(i, (b == 4 || b == 7) ? 0 : (last - i)));
    }
    if ((a[i] == 4 || a[i] == 7) && last - i <= k) break;
    if (a[i] == 4 || a[i] == 7) last = i;
  }
  int C = 0;
  for (int i = n - 1; i >= 0; i--) C = add(mul(C, 10), a[i]);
  return del(del(C, 1), R);
}
int main() {
  int testcases;
  scanf("%d%d", &testcases, &k);
  memset(f, 255, sizeof(f));
  for (; testcases > 0; testcases--) {
    readin();
    int R1 = solve();
    readin();
    addone();
    int R2 = solve();
    int R = del(R2, R1);
    printf("%d\n", R);
  }
  return 0;
}