#include <bits/stdc++.h>
using namespace std;
const int inf_int = 2e9;
const long long inf_ll = 2e18;
int Gcd(int p, int q) { return q == 0 ? p : Gcd(q, p % q); }
int Pow(int p, int q) {
  int ans = 1;
  while (q) {
    if (q & 1) ans = ans * p;
    p = p * p;
    q >>= 1;
  }
  return ans;
}
inline long long read() {
  long long ra, fh;
  char rx;
  rx = getchar(), ra = 0, fh = 1;
  while ((rx < '0' || rx > '9') && rx != '-') rx = getchar();
  if (rx == '-') fh = -1, rx = getchar();
  while (rx >= '0' && rx <= '9') ra *= 10, ra += rx - 48, rx = getchar();
  return ra * fh;
}
long long a[100005];
long long b[100005];
long long f[10];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  n = read(), k = read();
  f[0] = 1;
  for (int i = 1; i <= n / k; i++) a[i] = read();
  for (int i = 1; i <= n / k; i++) b[i] = read();
  for (int i = 1; i <= 10; i++) f[i] = f[i - 1] * 10;
  long long ans = 1;
  for (int i = 1; i <= n / k; i++) {
    long long t1 = (f[k] - 1) / a[i] + 1;
    long long t2 = (f[k - 1] - 1) / a[i] + 1;
    long long t3 =
        (f[k - 1] * (b[i] + 1) - 1) / a[i] - (f[k - 1] * b[i] - 1) / a[i];
    if (b[i] == 0)
      ans *= t1 - t2;
    else
      ans *= t1 - t3;
    ans %= 1000000007;
  }
  printf("%I64d\n", ans);
  return 0;
}
