#include <bits/stdc++.h>
using namespace std;
long long full, n, k, x, i, ans, a[100001], b[100001];
void f(long long l, long long r, long long d) {
  if (l > r) return;
  if (l == 0)
    ans += r / d + 1;
  else
    ans += (r / d) - (l - 1) / d;
}
int main() {
  cin >> n >> k;
  for (i = 1; i <= n / k; i++) {
    cin >> a[i];
  }
  x = 1;
  for (i = 1; i < k; i++) x *= 10;
  for (i = 1; i <= n / k; i++) {
    cin >> b[i];
  }
  full = 1;
  for (i = 1; i <= n / k; i++) {
    ans = 0;
    f(0, b[i] * x - 1, a[i]);
    f((b[i] + 1) * x, 10 * x - 1, a[i]);
    full = ans * full % 1000000007;
  }
  cout << full;
  return 0;
}
