#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long a[100005];
long long b[100005];
int main() {
  long long n, k;
  cin >> n >> k;
  for (int i = 0; i < (n / k); i++) {
    cin >> a[i];
  }
  for (int i = 0; i < (n / k); i++) {
    cin >> b[i];
  }
  long long sz = n / k;
  long long xx = 1;
  for (int i = 0; i < k; i++) xx *= 10;
  xx--;
  long long ans = 1;
  for (int i = 0; i < sz; i++) {
    long long cnt = xx / a[i] + 1;
    long long dc;
    if (b[i] != 0) {
      long long x = b[i] * (xx + 1) / 10 - 1;
      int y = (b[i] + 1) * (xx + 1) / 10 - 1;
      dc = y / a[i];
      dc -= x / a[i];
    } else {
      long long x = (xx + 1) / 10 - 1;
      dc = x / a[i] + 1;
    }
    cnt -= dc;
    ans *= cnt;
    ans %= MOD;
  }
  cout << ans << endl;
}
