#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  long long a[n / k], c[n / k], t[10], x = 1, mod = 1000000007;
  int b[n / k];
  for (int i = 0; i < 10; i++) {
    t[i] = x;
    x *= 10;
  }
  for (int i = 0; i < n / k; i++) {
    cin >> a[i];
    c[i] = ceil((double)t[k] / a[i]);
  }
  x = 1;
  for (int i = 0; i < n / k; i++) {
    cin >> b[i];
    c[i] -= ((ceil(((b[i] + 1) * t[k - 1]) / (double)a[i])) -
             (ceil((b[i] * t[k - 1]) / (double)a[i])));
    x = (((x % mod) * (c[i] % mod)) % mod);
  }
  cout << (x + mod) % mod << endl;
  return 0;
}
