#include <bits/stdc++.h>
using namespace std;
class UnionFind {
 private:
  vector<int> p, rank;

 public:
  UnionFind(int N) {
    rank.assign(N, 0);
    p.assign(N, 0);
    for (int i = 0; i < N; i++) {
      p[i] = i;
    }
  }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) {
    if (!isSameSet(i, j)) {
      int x = findSet(i), y = findSet(j);
      if (rank[x] > rank[y])
        p[y] = x;
      else {
        p[x] = y;
        if (rank[x] == rank[y]) rank[y]++;
      }
    }
  }
};
class SegmentTree {
 private:
  vector<int> st, A;
  int n;
  int left(int p) { return p << 1; }
  int right(int p) { return (p << 1) + 1; }
  void build(int p, int L, int R) {
    if (L == R)
      st[p] = L;
    else {
      build(left(p), L, (L + R) / 2);
      build(right(p), (L + R) / 2 + 1, R);
      int p1 = st[left(p)], p2 = st[right(p)];
      st[p] = (A[p1] <= A[p2]) ? p1 : p2;
    }
  }
  int rmq(int p, int L, int R, int i, int j) {
    if (i > R || j < L) return -1;
    if (L >= i && R <= j) return st[p];
    int p1 = rmq(left(p), L, (L + R) / 2, i, j);
    int p2 = rmq(right(p), (L + R) / 2 + 1, R, i, j);
    if (p1 == -1) return p2;
    if (p2 == -1) return p1;
    return (A[p1] <= A[p2]) ? p1 : p2;
  }
  int update_point(int p, int L, int R, int idx, int new_value) {
    int i = idx, j = idx;
    if (i > R || j < L) return st[p];
    if (L == i && R == j) {
      A[i] = new_value;
      return st[p] = L;
    }
    int p1, p2;
    p1 = update_point(left(p), L, (L + R) / 2, idx, new_value);
    p2 = update_point(right(p), (L + R) / 2 + 1, R, idx, new_value);
    return st[p] = (A[p1] <= A[p2]) ? p1 : p2;
  }

 public:
  SegmentTree(const vector<int> &_A) {
    A = _A;
    n = (int)A.size();
    st.assign(4 * n, 0);
    build(1, 0, n - 1);
  }
  int rmq(int i, int j) { return rmq(1, 0, n - 1, i, j); }
  int update_point(int idx, int new_value) {
    return update_point(1, 0, n - 1, idx, new_value);
  }
};
class FenwickTree {
 private:
  vector<int> ft;

 public:
  FenwickTree(int n) { ft.assign(n + 1, 0); }
  int rsq(int b) {
    int sum = 0;
    for (; b; b -= (b & (-b))) sum += ft[b];
    return sum;
  }
  void adjust(int k, int v) {
    for (; k < (int)ft.size(); k += (k & (-k))) {
      ft[k] += v;
    }
  }
};
long long a[100008];
long long b[100008];
long long cnt[100008];
int main() {
  long long n;
  long long k;
  cin >> n >> k;
  for (int i = int(1); i <= int(n / k); i++) cin >> a[i];
  for (int i = int(1); i <= int(n / k); i++) cin >> b[i];
  long long ans = 1;
  long long ln = 1;
  for (int i = int(1); i <= int(k - 1); i++) {
    ln *= 10;
  }
  memset((cnt), 0, sizeof(cnt));
  for (int i = int(1); i <= int(n / k); i++) {
    long long cmp = 0, low = 0, high = 0;
    cmp = b[i] * ln;
    low = cmp / a[i];
    if (cmp % a[i] == 0) low--;
    cmp = (b[i] + 1) * ln;
    high += cmp / a[i];
    if (cmp % a[i] == 0) high--;
    cnt[i] = (ln * 10 - 1) / a[i] + 1 - (high - low);
    cnt[i] %= 1000000007;
  }
  for (int i = int(1); i <= int(n / k); i++) {
    ans *= cnt[i];
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}
