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>
struct MI {
 private:
  char bb[4096];
  FILE* f;
  char *bs, *be;
  char e;
  bool o, l;

 public:
  MI() : f(stdin) {}
  MI(FILE* f) : f(f), bs(0), be(0) {}
  MI(const char* s) : f(fmemopen(const_cast<char*>(s), strlen(s), "r")) {}
  inline operator bool() { return !l; }
  inline char get() {
    if (o) {
      o = 0;
      return e;
    }
    if (bs == be) be = (bs = bb) + fread(bb, 1, sizeof(bb), f);
    if (bs == be) {
      l = 1;
      return -1;
    };
    return *bs++;
  }
  inline void unget(char c) {
    o = 1;
    e = c;
  }
  template <typename T>
  inline T read() {
    T r;
    *this > r;
    return r;
  }
  template <typename T>
  inline MI& operator>(T&);
};
template <typename T>
struct Q {
  const static bool U = T(-1) >= T(0);
  inline void operator()(MI& t, T& r) const {
    r = 0;
    char c;
    bool y = 0;
    if (U)
      for (;;) {
        c = t.get();
        if (c == -1) goto E;
        if (isdigit(c)) break;
      }
    else
      for (;;) {
        c = t.get();
        if (c == -1) goto E;
        if (c == '-') {
          c = t.get();
          if (isdigit(c)) {
            y = 1;
            break;
          };
        } else if (isdigit(c))
          break;
        ;
      };
    for (;;) {
      if (c == -1) goto E;
      if (isdigit(c))
        r = r * 10 + (c ^ 48);
      else
        break;
      c = t.get();
    }
    t.unget(c);
  E:;
    if (y) r = -r;
  }
};
template <>
struct Q<char> {
  inline void operator()(MI& t, char& r) {
    int c;
    for (;;) {
      c = t.get();
      if (c == -1) return void(r = -1);
      if (!isspace(c)) return void(r = c);
    }
  }
};
template <typename T>
inline MI& MI::operator>(T& t) {
  Q<T>()(*this, t);
  return *this;
}
template <typename T>
std::ostream& operator<(std::ostream& out, const T& t) {
  return out << t;
}
MI in;
const int lmax = 1002;
const long long lp = 1000000007;
using std::cout;
int n, k;
int a[lmax];
long long magic[lmax][lmax][2];
long long dfs(int x, int si, bool ok, bool top) {
  if (!x) return ok;
  int i;
  long long& ret = magic[x][si][ok];
  if ((!top) && ~ret) return ret;
  const int lim = top ? a[x] : 9;
  const int sub = si ? (si - 1) : 0;
  long long rr = 0;
  for (i = 0; i <= lim; i++) {
    if (i == 4 || i == 7)
      rr += dfs(x - 1, k, ok || si, top && i == lim);
    else
      rr += dfs(x - 1, sub, ok, top && i == lim);
  }
  rr %= lp;
  if (!top) ret = rr;
  return rr;
}
inline long long solve() { return dfs(n, 0, 0, 1); }
int main() {
  memset(magic, -1, sizeof(magic));
  int i, T;
  char c;
  in > T > k;
  while (T--) {
    while (!isdigit(c = in.get()))
      ;
    for (n = 1;; n++) {
      a[n] = c - '0';
      if (!isdigit(c = in.get())) break;
    }
    std::reverse(a + 1, a + n + 1);
    for (i = 1; i <= n && !a[i]; i++) a[i] = 9;
    --a[i];
    n -= !a[n];
    long long ans = lp - solve();
    while (!isdigit(c = in.get()))
      ;
    for (n = 1;; n++) {
      a[n] = c - '0';
      if (!isdigit(c = in.get())) break;
    }
    std::reverse(a + 1, a + n + 1);
    (ans += solve()) %= lp;
    cout < ans < ('\n');
  }
  return 0;
}