#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long dx[] = {-1, 0, 1, 0};
long long dy[] = {0, -1, 0, 1};
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n / k), b(n / k);
  for (long long i = 0; i < n / k; i++) cin >> a[i];
  for (long long i = 0; i < n / k; i++) cin >> b[i];
  long long ans = 1;
  long long p = pow(10, k - 1);
  for (long long i = 0; i < n / k; i++) {
    long long x = a[i];
    long long y = b[i];
    y++;
    long long s = 0;
    for (long long j = 1; j <= 10; j++) {
      long long val = (p * j - 1) / x + 1;
      long long val2 = p * (j - 1) - 1;
      val2 /= x;
      val2++;
      if (j == 1) val2 = 0;
      if (j != y) s += (val - val2);
    }
    ans *= s;
    ans %= mod;
  }
  cout << ans;
}
