#include <bits/stdc++.h>
using namespace std;
long long p[10];
int a1[100000];
int main() {
  p[0] = 1;
  for (int i = 1; i < 10; ++i) p[i] = p[i - 1] * 10;
  int n, k, m, a;
  long long o = 1;
  scanf("%d%d", &n, &k);
  m = n / k;
  for (int i = 0; i < m; ++i) scanf("%d", a1 + i);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &a);
    o = o *
        ((p[k] - 1) / a1[i] - ((a + 1) * p[k - 1] - 1) / a1[i] +
         (a * p[k - 1] + a1[i] - 1) / a1[i]) %
        1000000007;
  }
  printf("%d\n", o);
}
