#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k, tmp, pw, ans, tmpx, tmpy;
  vector<long long> veca, vecb;
  cin >> n >> k;
  veca.resize(n / k);
  vecb.resize(n / k);
  for (int i = 0; i < n / k; i++) cin >> veca[i];
  for (int i = 0; i < n / k; i++) cin >> vecb[i];
  pw = 1;
  for (int i = 0; i < k - 1; i++) pw *= 10;
  ans = 1;
  for (int i = 0; i < n / k; i++) {
    if (vecb[i] != 0)
      tmpx = (vecb[i] * pw) - 1;
    else
      tmpx = 0;
    tmpy = ((vecb[i] + 1) * pw) - 1;
    tmp = (tmpy / veca[i]) - (tmpx / veca[i]);
    tmpx = (10 * pw - 1) / veca[i];
    tmpy = tmpx - tmp;
    if (vecb[i] != 0) tmpy += 1;
    ans *= tmpy;
    ans %= 1000000007;
  }
  cout << ans % 1000000007 << "\n";
  veca.clear();
  vecb.clear();
  return 0;
}
