#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int a[100000], b[100000];
int main() {
  int n, k, n1, n2;
  long long int v = 1, ans = 1;
  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = 0; i < n / k; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n / k; i++) scanf("%d", &b[i]);
  for (int i = 0; i < k; i++) v *= 10;
  for (int i = 0; i < n / k; i++) {
    n1 = (v - 1) / a[i] + 1;
    long long int val = b[i] * (v / 10), val2 = (b[i] + 1) * (v / 10) - 1;
    if (val % a[i] != 0) val += (a[i] - val % a[i]);
    if (val <= val2)
      n2 = (val2 - val) / a[i] + 1;
    else
      n2 = 0;
    ans = (ans * (n1 - n2)) % M;
  }
  cout << ans;
  return 0;
}
