#include <bits/stdc++.h>
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
using namespace std;
int a[100005], b[100005];
int main() {
  ios::sync_with_stdio(false);
  long long int n, k;
  cin >> n >> k;
  long long int len = n / k, ans = 1, x;
  for (__typeof(len) i = (0) - ((0) > (len)); i != (len) - ((0) > (len));
       i += 1 - 2 * ((0) > (len)))
    cin >> a[i];
  for (__typeof(len) i = (0) - ((0) > (len)); i != (len) - ((0) > (len));
       i += 1 - 2 * ((0) > (len)))
    cin >> b[i];
  long long int tot = round(pow(10, k)) - 1, n1, n2, n3;
  for (__typeof(len) i = (0) - ((0) > (len)); i != (len) - ((0) > (len));
       i += 1 - 2 * ((0) > (len))) {
    n1 = 0;
    n2 = 0;
    n1 = ((b[i] + 1) * (round(pow(10, k - 1)))) - 1;
    n1 = (n1 / a[i]) + 1;
    if (b[i]) {
      n2 = (b[i] * round(pow(10, k - 1))) - 1;
      n2 = (n2 / a[i]) + 1;
    }
    n1 = n1 - n2;
    n2 = (tot / a[i]) + 1;
    x = (n2 - n1);
    ans = ((ans % 1000000007) * (x % 1000000007)) % 1000000007;
  }
  if (ans < 0) ans += 1000000007;
  cout << ans;
  return 0;
}
