#include <bits/stdc++.h>
using namespace std;
long long r = 1000000007;
int h[10];
int n, k, m, i, j;
long long a[100001], b[100001];
long long ans, x, y, z, c1, c2;
int main() {
  cin >> n >> k;
  for (i = 1; i <= n / k; i++) cin >> a[i];
  for (i = 1; i <= n / k; i++) cin >> b[i];
  h[0] = 1;
  for (i = 1; i <= 9; i++) h[i] = h[i - 1] * 10;
  ans = 1;
  for (i = 1; i <= n / k; i++) {
    x = 9;
    for (j = 2; j <= k; j++) x = x * 10 + 9;
    c1 = x / a[i] + 1;
    x = b[i] * h[k - 1];
    z = x % a[i];
    if (z > 0) x = x + (a[i] - z);
    y = b[i];
    for (j = 2; j <= k; j++) y = y * 10 + 9;
    z = y % a[i];
    if (z > 0) y = y - z;
    c2 = (y - x) / a[i] + 1;
    ans = ans * (c1 - c2) % r;
  }
  cout << ans << endl;
}
