#include <bits/stdc++.h>
int main() {
  long long q[10];
  long long n, k, a, i, ans = 1;
  q[0] = 1;
  for (i = 1; i <= 9; i++) {
    q[i] = q[i - 1] * 10;
  }
  scanf("%d%d", &n, &k);
  a = n / k;
  long long s1[100000], s2[100000];
  for (i = 0; i < a; i++) {
    scanf("%lld", &s1[i]);
  }
  for (i = 0; i < a; i++) {
    scanf("%lld", &s2[i]);
  }
  for (i = 0; i < a; i++) {
    long long num1 = (q[k] - 1) / s1[i] + 1;
    long long num2 = (q[k - 1] - 1) / s1[i] + 1;
    long long num3 = (q[k - 1] * (s2[i] + 1) - 1) / s1[i] + 1 -
                     (q[k - 1] * s2[i] - 1) / s1[i] - 1;
    if (s2[i] == 0)
      ans *= num1 - num2;
    else
      ans *= num1 - num3;
    ans %= 1000000007;
  }
  printf("%lld", ans);
  return 0;
}
