#include <bits/stdc++.h>
const int MAXN = 300005;
using namespace std;
int n, k;
long long ans = 1, pw;
long long a[MAXN], b[MAXN];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n / k; i++) scanf("%lld", a + i);
  for (int i = 0; i < n / k; i++) scanf("%lld", b + i);
  pw = 1;
  for (int i = 0; i < k; i++) pw *= 10;
  for (int i = 0; i < n / k; i++) {
    long long all = (pw - 1) / a[i] + 1;
    long long x = b[i] * (pw / 10) - 1;
    long long y = (b[i] + 1) * (pw / 10) - 1;
    if (x < 0) {
      all -= (y / a[i] + 1);
      ans = (ans * all) % 1000000007;
    } else if (x >= 0) {
      all -= (y / a[i] - x / a[i]);
      ans = (ans * all) % 1000000007;
    }
  }
  printf("%lld", ans);
}
