#include <bits/stdc++.h>
const double EPS = 1e-10;
const int mod = 1e9 + 7;
using namespace std;
inline int rit() {
  int f = 0, key = 1;
  char c;
  do {
    c = getchar();
    if (c == '-') key = -1;
  } while (c < '0' || c > '9');
  do {
    f = f * 10 + c - '0';
    c = getchar();
  } while (c >= '0' && c <= '9');
  return f * key;
}
int n, k;
int a[100005], b[100005];
int chk(int L, int R, int x) {
  if (L == 0)
    return (R / x) + 1;
  else
    return (chk(0, R, x) - chk(0, L - 1, x));
}
void read() {
  int i, f;
  long long ans, x;
  n = rit(), k = rit();
  f = n / k;
  for (i = 0; i < f; i++) {
    a[i] = rit();
  }
  for (i = 0; i < f; i++) {
    b[i] = rit();
  }
  for (x = 1, i = 0; i < k; i++) x *= 10;
  for (i = 0, ans = 1; i < f; i++) {
    ans = ans * (chk(0, x - 1, a[i]) -
                 chk((x / 10) * b[i], (x / 10) * (b[i] + 1) - 1, a[i]));
    ans = ans % mod;
  }
  printf("%d\n", ans);
}
int main() {
  read();
  return 0;
}
