#include <bits/stdc++.h>
long long A[100010];
long long P[100010];
int main() {
  long long a, b, c, d, e, res = 1;
  P[0] = 1;
  for (a = 1; a < 100010; a++) {
    P[a] = (P[a - 1] * 10) % 1000000007;
  }
  scanf("%lld %lld", &a, &b);
  for (c = 0; c < a / b; c++) {
    scanf("%lld", &A[c]);
  }
  for (res = 1, c = 0; c < a / b; c++) {
    scanf("%lld", &d);
    e = (P[b] - 1) / A[c] + 1;
    e -= (P[b - 1] * (d + 1) - 1) / A[c] + 1;
    if (d != 0) {
      e += (P[b - 1] * d - 1) / A[c] + 1;
    }
    e = e % 1000000007;
    res = (res * e) % 1000000007;
  }
  printf("%lld\n", res);
}
