#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-10;
const int INF = (int)(1e9);
const long long mod = (int)(1e+9 + 7);
const int N = (int)(1e5);
int days_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int a[N];
int b[N];
int n, k;
int f(int first_dig, int i) {
  if (first_dig < 0) return 0;
  long long num = first_dig;
  for (int i = 0; i < k - 1; i++) {
    num = num * 10 + 9;
  }
  return (num / a[i] + 1) % mod;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n / k; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n / k; i++) {
    scanf("%d", &b[i]);
  }
  long long ans = 1;
  for (int i = 0; i < n / k; i++) {
    long long cur = 0;
    cur += f(9, i);
    cur -= f(b[i], i);
    cur += f(b[i] - 1, i);
    cur %= mod;
    ans = (ans * cur) % mod;
  }
  cout << ans;
  return 0;
}
