#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int a[MAXN], b[MAXN];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n / k; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n / k; ++i) {
    scanf("%d", &b[i]);
  }
  long long ans = 1;
  int mx = 10;
  for (int i = 1; i < k; ++i) {
    mx *= 10;
  }
  int mn = mx / 10;
  --mx;
  for (int i = 0; i < n / k; ++i) {
    int cur = mx / a[i];
    int l = b[i] * mn, r = (b[i] + 1) * mn - 1;
    if (r >= l) {
      cur -= r / a[i];
      if (l > 0) cur += (l - 1) / a[i];
    }
    if (b[i] != 0) ++cur;
    ans = (ans * (long long)cur) % 1000000007;
  }
  printf("%I64d", ans);
  return 0;
}
