#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> a(n / k);
  vector<int> b(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]);
  vector<long long int> p(10);
  p[0] = 1;
  for (int i = 1; i <= 9; i++) p[i] = p[i - 1] * 10;
  long long int count = 0;
  long long int sum = 1;
  int flag = 0;
  long long int power = p[k];
  int po = p[k - 1];
  long long int number;
  long long int am = 0;
  long long int bm = 0;
  long long int tm = 0;
  for (int i = 0; i < (n / k); i++) {
    if (b[i] != 0)
      count = 1;
    else
      count = 0;
    number = b[i] * po + (po - 1);
    am = number / a[i];
    if (b[i] == 0)
      bm = 0;
    else {
      number = (b[i] * po) - 1;
      bm = number / a[i];
    }
    tm = (power - 1) / a[i];
    tm = (tm - (am - bm) + 1000000007) % 1000000007;
    count = (count + tm) % 1000000007;
    sum = (sum * count) % 1000000007;
  }
  cout << sum << endl;
  return 0;
}
