#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  scanf("%lld", &n);
  scanf("%lld", &k);
  long long int i, j;
  long long int val = 0, val1 = 0, val2 = 1;
  for (i = 1; i < k; i++) {
    val = (val * 10) + 9;
    val2 = val2 * 10;
  }
  val1 = (val * 10) + 9;
  long long int arr[n + 5];
  long long int brr[n + 5];
  long long int m = n / k;
  for (i = 0; i < m; i++) {
    scanf("%lld", &arr[i]);
  }
  for (i = 0; i < m; i++) {
    scanf("%lld", &brr[i]);
  }
  long long int tot = 1;
  long long int mod = 1e9 + 7;
  for (i = 0; i < m; i++) {
    long long int t1 = val1 / arr[i];
    if (brr[i] != 0) t1++;
    long long int t2 = (brr[i] * val2) + val;
    long long int t3 = t2 / arr[i];
    long long int t4 = (max(0LL, brr[i] * val2 - 1)) / arr[i];
    t3 = t3 - t4;
    long long int t5 = t1 - t3;
    tot *= t5;
    tot %= mod;
  }
  cout << tot << "\n";
}
