#include <bits/stdc++.h>
using namespace std;
int xx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int yy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
const double pi = 3.14159265358;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, i, cnt, k, flag, b, ans;
  cin >> n >> k;
  cnt = k;
  flag = 1;
  while (cnt--) flag *= 10;
  cnt = 1;
  long long a[n];
  for (i = 0; i < n / k; i++) cin >> a[i];
  for (i = 0; i < n / k; i++) {
    cin >> b;
    ans = (flag - 1) / a[i];
    if (b != 0) {
      ans++;
      ans -= ((b + 1) * (flag / 10) - 1) / a[i] - (b * (flag / 10) - 1) / a[i];
    } else
      ans -= (flag / 10 - 1) / a[i];
    cnt = (cnt * ans) % 1000000007;
  }
  cout << cnt << endl;
  return 0;
}
