#include <bits/stdc++.h>
using namespace std;
long long f[10];
void ge() {
  f[0] = 1;
  for (int i = 1; i <= 9; i++) {
    f[i] = f[i - 1] * 10;
  }
}
long long a[100005], b[100005];
int main() {
  ge();
  int n, k;
  long long ans = 1;
  int i, j;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n / k; i++) {
    scanf("%I64d", &a[i]);
  }
  for (i = 0; i < n / k; i++) {
    scanf("%I64d", &b[i]);
  }
  for (i = 0; i < n / k; i++) {
    long long n1 = (f[k] - 1) / a[i] + 1;
    long long n2 = (f[k - 1] - 1) / a[i] + 1;
    long long n3 = (f[k - 1] * (b[i] + 1) - 1) / a[i] + 1 -
                   (f[k - 1] * b[i] - 1) / a[i] - 1;
    if (b[i] == 0)
      ans *= n1 - n2;
    else
      ans *= n1 - n3;
    ans %= 1000000007;
  }
  printf("%I64d", ans);
  return 0;
}
