#include <bits/stdc++.h>
using namespace std;
long long int modulo = 1000000000 + 7;
int main() {
  int maxvalue;
  int n, k, good = 0, a[100001], b[100001];
  cin >> n >> k;
  int nr = k, nr2 = k - 1, val2;
  maxvalue = 1;
  int maxvalue2 = 1;
  while (nr > 0) maxvalue *= 10, nr--;
  maxvalue2 = maxvalue / 10;
  maxvalue--;
  for (int i = 0; i < n / k; i++) cin >> a[i];
  for (int i = 0; i < n / k; i++) cin >> b[i];
  for (int i = 0; i < n / k; i++) {
    val2 = maxvalue / a[i] + (b[i] * maxvalue2 - ((b[i] != 0) ? 1 : 0)) / a[i] -
           ((b[i] + 1) * maxvalue2 - 1) / a[i];
    if (b[i] != 0) val2++;
    if (val2 != 0)
      if (good != 0)
        good = ((good % modulo) * (val2 % modulo)) % modulo;
      else
        good = val2;
  }
  cout << good;
  return 0;
}
