#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 4;
int n, k;
int a[maxn], b[maxn];
int cnt[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  int nbyk = n / k;
  for (long long i = 0; i < (long long)nbyk; i++) cin >> a[i];
  for (long long i = 0; i < (long long)nbyk; i++) cin >> b[i];
  long long maxs = (long long)(pow(10.0, k) + 1e-9);
  long long tod = maxs / 10;
  maxs--;
  long long ans = 1;
  for (long long i = 0; i < (long long)nbyk; i++) {
    cnt[i] += ((maxs / a[i]));
    long long d1 = (((b[i] + 1) * tod) - 1) / a[i];
    long long d2 = ((b[i]) * tod) / a[i];
    cnt[i] -= (d1 - d2);
    int a2 = ((b[i]) * tod) % a[i];
    cnt[i] = cnt[i] - (a2 == 0);
    cnt[i] += 1;
  }
  for (long long i = 0; i < (long long)nbyk; i++) {
    ans *= cnt[i];
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}
