#include <bits/stdc++.h>
using namespace std;
int a[110000], b[110000];
int ans[110000];
const int mod = 1e9 + 7;
int PW[10];
int cal(int p, int k) { return p * PW[k] - 1; }
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int m = n / k;
  PW[0] = 1;
  for (int i = 1; i < 10; i++) PW[i] = PW[i - 1] * 10;
  for (int i = 0; i < m; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) scanf("%d", &b[i]);
  k--;
  for (int i = 0; i < m; i++) {
    if (b[i] == 0)
      ans[i] = cal(10, k) / a[i] + 1 - (cal(1, k) / a[i] + 1);
    else
      ans[i] = cal(b[i], k) / a[i] + 1 + cal(10, k) / a[i] + 1 -
               (cal(b[i] + 1, k) / a[i] + 1);
  }
  long long anss = 1;
  for (int i = 0; i < m; i++) {
    anss = anss * ans[i] % mod;
  }
  printf("%I64d\n", anss);
  return 0;
}
