#include <bits/stdc++.h>
using namespace std;
int n, m, k, maxi, sum, a[100005], b[100005];
long long ans = 1, tmp = 1, cnt;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i < k; i++) tmp *= 10;
  for (int i = 1; i <= n / k; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n / k; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n / k; i++) {
    cnt = (tmp * 10 - 1) / a[i];
    cnt -= (tmp * (b[i] + 1) - 1) / a[i];
    if (b[i] != 0) cnt += (tmp * b[i] - 1) / a[i] + 1;
    ans = ans * cnt % 1000000007;
  }
  printf("%I64d\n", ans);
  return 0;
}
