#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100, mod = 1e9 + 7;
int aa[N], ba[N], n, k, a, b;
int get(int v) { return v / a + 1; }
int main() {
  cin >> n >> k;
  for (int i = 0; i < n / k; ++i) scanf("%d", &aa[i]);
  for (int i = 0; i < n / k; ++i) scanf("%d", &ba[i]);
  int out = 1, mx = 9, ml = 1;
  for (int i = 1; i < k; i++) mx = 10 * mx + 9, ml *= 10;
  for (int j = 0; j < n / k; j++) {
    a = aa[j];
    b = ba[j];
    int c = get(mx);
    if (!b)
      c -= (get(mx / 10));
    else {
      c -= get(ml * b + mx / 10);
      c += get(ml * (b - 1) + mx / 10);
    }
    out = (1LL * out * c) % mod;
  }
  cout << out << endl;
}
