#include <bits/stdc++.h>
using namespace std;
typedef priority_queue<long long> prq;
template <typename T>
using min_prq = priority_queue<T, vector<T>, greater<T>>;
inline long long pmod(long long i, long long n) { return (i % n + n) % n; }
const int mod = 1e9 + 7;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n / k), b(n / k);
  for (long long(i) = (0); (i) <= ((n / k) - 1); ++(i)) {
    cin >> a[i];
  }
  for (long long(i) = (0); (i) <= ((n / k) - 1); ++(i)) {
    cin >> b[i];
  }
  long long count = 1;
  long long maxy = pow(10, k) - 1;
  string useful = "";
  for (long long(i) = (0); (i) <= (k - 2); ++(i)) {
    useful += '9';
  }
  for (long long(i) = (0); (i) <= ((n / k) - 1); ++(i)) {
    long long curr_count;
    if (b[i] == 0) {
      curr_count = 0;
    } else {
      curr_count = 1;
    }
    curr_count += (maxy / a[i]) % mod;
    if (b[i] > 0) {
      string useful1 = to_string(b[i]) + useful;
      int one = stoi(useful1);
      string useful2 = to_string(b[i] - 1) + useful;
      int two = stoi(useful2);
      curr_count = (curr_count - (one / a[i])) % mod;
      curr_count = (curr_count + (two / a[i])) % mod;
    } else {
      string useful1 = to_string(b[i]) + useful;
      int one = stoi(useful1);
      curr_count = (curr_count - (one / a[i])) % mod;
    }
    if (curr_count != 0) count = (count * curr_count) % mod;
  }
  cout << count % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  for (long long(T) = (1); (T) <= (t); ++(T)) {
    solve();
  }
  return 0;
}
