#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 922337203685477;
const long long mininf = -922337203685477;
const long long nax = 1e5 + 5;
long long n, k, a[nax], b[nax], ans, p;
long long f(long long x, long long y) {
  long long ret = p / x + 1;
  long long top = (p + 1) / 10 * (y + 1) - 1;
  long long bot = (p + 1) / 10 * y;
  long long first = bot / x;
  if (bot % x != 0) {
    first++;
  }
  long long last = top / x;
  return ret - (last - first + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (long long i = 0; i < n / k; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n / k; i++) {
    cin >> b[i];
  }
  p = 1;
  for (long long i = 1; i <= k; i++) {
    p *= 10;
  }
  p--;
  ans = 1;
  for (long long i = 0; i < n / k; i++) {
    ans = ans * f(a[i], b[i]) % mod;
  }
  cout << ans << '\n';
}
