#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  long long s = 1;
  cin >> n >> k;
  int l = int(pow(10.0, k - 1));
  int *A = new int[n / k];
  for (int i = 0; i < n / k; i++) cin >> A[i];
  int a;
  for (int i = 0; i < n / k; i++) {
    cin >> a;
    int r = (a * l) % A[i], b = (10 * l - 1) / A[i] + 1;
    r = (r == 0 ? 0 : A[i] - r);
    int x = (r > l - 1 ? 0 : (l - 1 - r) / A[i] + 1);
    int m = x;
    int c = (b - m) % 1000000007;
    s = (s * c) % 1000000007;
  }
  cout << s;
}
