#include <bits/stdc++.h>
using namespace std;
long long modpow(int a, int b, int m) {
  long long res = 1;
  long long base = a;
  base %= m;
  while (b > 0) {
    if (b % 2 == 1) {
      res = (res * base) % m;
    }
    b >>= 1;
    base = (base * base) % m;
  }
  return res;
}
long long modInverse(int a, int m) { return modpow(a, m - 2, m); }
long long modify(long long num) { return (num + 1000000007) % 1000000007; }
long long mypow(int base, int exp) {
  long long ret = 1;
  for (int i = 0; i < (exp); ++i) {
    ret *= base;
  }
  return ret;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a;
  vector<int> b;
  for (int i = 0; i < (n / k); ++i) {
    int nxt;
    cin >> nxt;
    a.push_back(nxt);
  }
  for (int i = 0; i < (n / k); ++i) {
    int nxt;
    cin >> nxt;
    b.push_back(nxt);
  }
  long long ans = 1;
  for (int i = 0; i < (n / k); ++i) {
    long long minians = 0;
    for (int dig = 0; dig <= 9; dig++) {
      if (dig == b[i]) continue;
      long long top = (long long)(dig + 1) * mypow(10, k - 1) - 1l;
      long long bot = (long long)(dig)*mypow(10, k - 1) - 1l;
      long long topcnt = (long long)(top / a[i]);
      topcnt++;
      if (dig == 0) {
        minians += topcnt;
        continue;
      }
      long long botcnt = (long long)(bot / a[i]);
      botcnt++;
      minians += topcnt - botcnt;
      minians = (minians + 1000000007) % 1000000007;
    }
    ans = (ans * minians) % 1000000007;
  }
  cout << ans << endl;
}
