#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> A(n / k), B(n / k);
  for (int i = 0; i < n / k; ++i) cin >> A[i];
  for (int i = 0; i < n / k; ++i) cin >> B[i];
  long long ans = 1;
  for (int i = 0; i < n / k; ++i) {
    long long all = ((long long)pow(10, k) - 1) / A[i] + (B[i] != 0);
    all -= ((B[i] + 1) * (long long)pow(10, k - 1) - 1) / A[i];
    all += B[i] == 0 ? 0 : (B[i] * (long long)pow(10.0, k - 1) - 1) / A[i];
    all = all % mod;
    ans = (ans * all) % mod;
  }
  cout << ans << "\n";
  return 0;
}
