#include <bits/stdc++.h>
const int MAX = 1e5 + 9, MOD = 1e9 + 7;
using namespace std;
int a[MAX], b[MAX], n, k, i, j, r, c, z = 1, from, how, nr, bgn, until;
int main() {
  long long t = 1;
  cin >> n >> k;
  c = n / k;
  for (i = 0; i < c; i++) cin >> a[i];
  for (i = 0; i < c; i++) cin >> b[i];
  for (i = 0; i < k; i++) z *= 10;
  for (i = 0; i < c; i++) {
    bgn = z / 10;
    from = bgn * b[i];
    until = from + bgn - 1;
    how = 0;
    if (from > 0) from--;
    how = until / a[i] - (from) / a[i];
    nr = (z - 1) / a[i] - how + (b[i] != 0);
    t *= nr;
    t = t % MOD;
  }
  cout << t;
}
