#include <bits/stdc++.h>
using namespace std;
long long n, k, a[(int)(2e5 + 10)], b[(int)(2e5 + 10)], t[(int)(2e5 + 10)], kat,
    ans = 1, m, temp;
int main() {
  t[0] = 1;
  cin >> n >> k;
  m = n / k;
  for (int i = 1; i <= m; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= m; i++) scanf("%lld", &b[i]);
  for (int i = 1; i <= 11; i++) t[i] = t[i - 1] * 10;
  for (int i = 1; i <= m; i++) {
    temp = ((t[k] - 1) / a[i] + 1) % 1000000007;
    temp = (temp - (((b[i] + 1) * t[k - 1] - 1) / a[i] + 1) + 1000000007) %
           1000000007;
    if (b[i])
      temp = (temp + (((b[i] * t[k - 1]) - 1) / a[i] + 1) % 1000000007) %
             1000000007;
    ans = (ans * temp) % 1000000007;
  }
  cout << ans << '\n';
}
