#include <bits/stdc++.h>
unsigned int make_number(unsigned int dig, unsigned int rep,
                         unsigned int start = 0) {
  for (unsigned int i = 0; i < rep; ++i) {
    start *= 10;
    start += dig;
  }
  return start;
}
int main() {
  unsigned int n, k;
  std::scanf("%u %u", &n, &k);
  unsigned int blocks = n / k;
  std::unique_ptr<int[]> a(new int[blocks]);
  std::unique_ptr<int[]> b(new int[blocks]);
  for (unsigned int i = 0; i < blocks; ++i) {
    std::scanf("%u", &a[i]);
  }
  for (unsigned int i = 0; i < blocks; ++i) {
    std::scanf("%u", &b[i]);
  }
  unsigned long long int total = 1;
  for (unsigned int i = 0; i < blocks; ++i) {
    unsigned int d = make_number(9, k) / a[i] + 1;
    unsigned int low = make_number(0, k - 1, b[i]);
    unsigned int d1 = low / a[i];
    unsigned int d2 = make_number(9, k - 1, b[i]) / a[i];
    d -= d2 - d1;
    d -= (d1 * a[i] == low) ? 1 : 0;
    total = (total * d) % 1000000007;
  }
  std::printf("%u", static_cast<unsigned int>(total));
  return 0;
}
