#include <bits/stdc++.h>
using namespace std;
int A[100005], B[100005];
long long pwr[15];
int main() {
  int n, k, i;
  long long res = 1, MOD = 1000000007, c;
  cin >> n >> k;
  for (i = 0; i < n / k; i++) cin >> A[i];
  for (i = 0; i < n / k; i++) cin >> B[i];
  for (i = pwr[0] = 1; i <= 10; i++) pwr[i] = 10 * pwr[i - 1];
  for (i = 0; i < n / k; i++) {
    long long l = pwr[k] - 1;
    l = l / A[i] + 1;
    long long t1 = pwr[k - 1];
    if (B[i]) {
      l = l - ((((B[i] + 1) * t1) - 1) / A[i] - ((B[i] * t1) - 1) / A[i]);
    } else {
      l = l - (((B[i] + 1) * t1) - 1) / A[i] - 1;
    }
    res = (res * l) % MOD;
  }
  cout << res;
  return 0;
}
