#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
const long long B = 1000000007;
long long a[N];
int b[N];
long long dv(long long x, long long a) {
  int k = x / a;
  if (x > 0 && x % a == 0) k--;
  if (x > 0) k++;
  return k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(15);
  int n, k;
  cin >> n >> k;
  int m = n / k;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  long long result = 1;
  long long x10_k = 1, x10_k_1 = 0;
  for (int i = 0; i < k; i++) {
    x10_k_1 = x10_k;
    x10_k *= 10;
  }
  for (int i = 0; i < m; i++) {
    long long x = (dv(x10_k, a[i]) - dv((b[i] + 1) * x10_k_1, a[i]) +
                   dv(b[i] * x10_k_1, a[i])) %
                  B;
    result = (result * x) % B;
  }
  cout << result << endl;
  return 0;
}
