#include <bits/stdc++.h>
using namespace std;
long long a[100002], b[100002], n, k;
long long p;
long long mx = 1;
long long m = 1;
int main() {
  scanf("%I64d", &n);
  scanf("%I64d", &k);
  p = n / k;
  for (int i = 0; i < p; i++) scanf("%I64d", &a[i]);
  for (int i = 0; i < p; i++) scanf("%I64d", &b[i]);
  for (int i = 0; i < k; i++) mx *= 10;
  m = mx / 10;
  mx--;
  long long ans = 1;
  for (int i = 0; i < p; i++) {
    long long low = b[i] * m - 1;
    if (low >= 0) {
      low = low / a[i];
      low++;
    } else {
      low = 0;
    }
    long long high = (b[i] + 1) * m - 1;
    high = mx / a[i] - high / a[i];
    long long sum =
        (low % (long long)1000000007 + high % (long long)1000000007) %
        (long long)1000000007;
    ans = ((ans % (long long)1000000007) * (sum % (long long)1000000007)) %
          (long long)1000000007;
  }
  cout << ans << endl;
  return 0;
}
