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;
long long int modulo = 1000000007;
long long int cuantos[1001][1001];
long long int cuantosmask[1001][1001];
int k;
void escriu(vector<int> v) {
  for (int i = 0; i < int(v.size()); i++) cout << v[i];
  cout << endl;
}
void computa() {
  for (int i = 0; i < 1001; i++) {
    for (int j = 0; j <= k; j++) {
      cuantos[i][j] = 0;
      cuantosmask[i][j] = 0;
    }
  }
  cuantos[0][k] = 1;
  for (int j = 0; j <= k; j++) cuantosmask[0][j] = 1;
  for (int i = 1; i < 1001; i++) {
    cuantos[i][0] = (2 * cuantos[i - 1][k]) % modulo;
    for (int j = 1; j <= k; j++) {
      cuantos[i][j] = (8 * cuantos[i - 1][j - 1]) % modulo;
    }
    cuantos[i][k] = (cuantos[i][k] + (8 * cuantos[i - 1][k]) % modulo) % modulo;
    cuantosmask[i][k] = cuantos[i][k];
    for (int j = k - 1; j >= 0; j--)
      cuantosmask[i][j] = (cuantosmask[i][j + 1] + cuantos[i][j]) % modulo;
  }
}
long long int cuantosmenores(vector<int> &v, int last) {
  long long int s = 0;
  int n = int(v.size());
  for (int i = 0; i < n; i++) {
    for (int d = 0; d < v[i]; d++) {
      if (not((d == 4 or d == 7) and i - last < k + 1)) {
        int megalast = last;
        if (d == 4 or d == 7) megalast = i;
        s = (s + cuantosmask[n - i - 1][max(0, k + megalast - i)]) % modulo;
      }
    }
    if (v[i] == 4 or v[i] == 7) {
      if (i - last < k + 1) {
        return s;
      }
      last = i;
    }
  }
  s = (s + 1) % modulo;
  return s;
}
long long int cuantosmayores(vector<int> &v, int last) {
  long long int s = 0;
  int n = int(v.size());
  for (int i = 0; i < n; i++) {
    for (int d = v[i] + 1; d <= 9; d++) {
      if (not((d == 4 or d == 7) and i - last < k + 1)) {
        int megalast = last;
        if (d == 4 or d == 7) megalast = i;
        s = (s + cuantosmask[n - i - 1][max(0, k + megalast - i)]) % modulo;
      }
    }
    if (v[i] == 4 or v[i] == 7) {
      if (i - last < k + 1) {
        return s;
      }
      last = i;
    }
  }
  s = (s + 1) % modulo;
  return s;
}
vector<int> estira(vector<int> v, int dist) {
  vector<int> r;
  for (int i = 0; i < dist; i++) r.push_back(0);
  for (int i = 0; i < int(v.size()); i++) r.push_back(v[i]);
  return r;
}
vector<int> recorta(vector<int> v, int p) {
  vector<int> r;
  for (int i = p; i < int(v.size()); i++) r.push_back(v[i]);
  return r;
}
long long int cuantosentre(vector<int> u, vector<int> v) {
  v = estira(v, int(u.size()) - int(v.size()));
  int index = 0;
  int n = int(u.size());
  int last = -k - 1;
  while (index < n and u[index] == v[index]) {
    if (u[index] == 4 or u[index] == 7) {
      if (index - last < k + 1) return 0;
      last = index;
    }
    index++;
  }
  if (index == n) return 1;
  u = recorta(u, index);
  v = recorta(v, index);
  last = last - index;
  n = int(u.size());
  if (u[0] < v[0]) return 0;
  long long int s = 0;
  for (int d = v[0] + 1; d < u[0]; d++) {
    if (not((d == 4 or d == 7) and last > -k - 1)) {
      int megalast = last;
      if (d == 4 or d == 7) megalast = 0;
      s = (s + cuantosmask[n - 1][max(0, k + megalast)]) % modulo;
    }
  }
  if (not((u[0] == 4 or u[0] == 7) and last > -k - 1)) {
    int lastu = last - 1;
    if (u[0] == 4 or u[0] == 7) lastu = -1;
    u = recorta(u, 1);
    s = (s + cuantosmenores(u, lastu)) % modulo;
  }
  if (not((v[0] == 4 or v[0] == 7) and last > -k - 1)) {
    int lastv = last - 1;
    if (v[0] == 4 or v[0] == 7) lastv = -1;
    v = recorta(v, 1);
    s = (s + cuantosmayores(v, lastv)) % modulo;
  }
  return s;
}
vector<int> stringtovector(string s) {
  vector<int> r;
  for (int i = 0; i < int(s.size()); i++) r.push_back(s[i] - '0');
  return r;
}
long long int calculavalor(vector<int> &v) {
  long long int s = 0;
  for (int i = 0; i < int(v.size()); i++) s = (s * 10 + v[i]) % modulo;
  return s;
}
long long int cuantostotal(vector<int> u, vector<int> v) {
  long long int vu = calculavalor(u);
  long long int vv = calculavalor(v);
  return (1 + vu + modulo - vv) % modulo;
}
int main() {
  int t;
  cin >> t >> k;
  computa();
  for (int i = 0; i < t; i++) {
    string s1, s2;
    cin >> s1 >> s2;
    vector<int> v = stringtovector(s1);
    vector<int> u = stringtovector(s2);
    long long int valor = cuantosentre(u, v);
    long long int tot = cuantostotal(u, v);
    cout << (modulo + tot - valor) % modulo << endl;
  }
}