#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long a[1000005], b[1000005];
long long nine[100], t[100];
int main() {
  int n, k;
  t[0] = 1LL;
  for (int i = (1); i <= (10); i++) t[i] = (t[i - 1] * 10LL) % mod;
  nine[1] = 9LL;
  for (int i = (2); i <= (10); i++) nine[i] = (nine[i - 1] * 10 + 9) % mod;
  long long ans = 1;
  scanf("%d", &(n));
  scanf("%d", &(k));
  for (int i = (1); i <= (n / k); i++) scanf("%lld", &(a[i]));
  for (int i = (1); i <= (n / k); i++) scanf("%lld", &(b[i]));
  t[0] = 0;
  nine[0] = 9;
  for (int i = (1); i <= (n / k); i++) {
    long long f = ((t[k] - 1) / a[i]) + 1;
    f %= mod;
    long long ss = b[i];
    long long temp = 0;
    long long st = ss * t[k - 1];
    long long e = st + nine[k - 1];
    if (k == 1) st = b[i];
    if (k == 1) e = st;
    temp = ((e / a[i]) - ((st - 1) / a[i]));
    if (st == 0) temp = e / a[i] + 1;
    f -= temp;
    if (f < mod) f += mod;
    ans = (ans * f) % mod;
  }
  cout << ans % mod << endl;
  return 0;
}
