#include <bits/stdc++.h>
using namespace std;
long long a[100000];
long long b[100000];
long long tavan(int x, long long y) {
  long long z = 1;
  for (int i = 0; i < y; i++) z = z * x;
  return z;
}
long long saghf(long long x, long long y) {
  if (x % y == 0)
    return x / y;
  else
    return (x / y) + 1;
}
int main() {
  long long n, k;
  long long p = 1000 * 1000 * 1000;
  p = p + 7;
  cin >> n >> k;
  for (int i = 0; i < n / k; i++) cin >> a[i];
  for (int i = 0; i < n / k; i++) cin >> b[i];
  long long s = 1;
  for (int i = 0; i < n / k; i++) {
    long long x, y;
    x = tavan(10, k);
    if (((b[i] * x) / 10) % a[i] == 0)
      s = s * (saghf(x, a[i]) - saghf(x / 10, a[i])) % p;
    else {
      if (a[i] - (((b[i] * x) / 10) % a[i]) > (x / 10) - 1)
        s = s * saghf(x, a[i]) % p;
      else {
        y = a[i] - (((b[i] * x) / 10) % a[i]);
        s = s * (saghf(x, a[i]) - saghf((x / 10) - y, a[i])) % p;
      }
    }
  }
  cout << s;
  return 0;
}
