#include <bits/stdc++.h>
using namespace std;
const int moo = 1000000000;
const int mo = 1000000007;
const int N = 300005;
int n, R[N], c[N];
int b[N], l, rem[N];
int f[2][N];
char s[N];
void UPD(int &x, int y) { (x += y) >= mo ? x -= mo : 233; }
int DIV(int v) {
  long long x = 0;
  for (int i = (int)(l); i >= (int)(1); i--) {
    x = x * moo + b[i];
    b[i] = x / v;
    x %= v;
  }
  for (; l && !b[l]; --l)
    ;
  return x;
}
int main() {
  scanf("%d", &n);
  R[1] = 1;
  R[n + 1] = 1e9;
  for (int i = (int)(2); i <= (int)(n); i++) scanf("%d", &R[i]);
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%d", &c[i]);
  scanf("%s", s + 1);
  l = strlen(s + 1);
  reverse(s + 1, s + l + 1);
  for (int i = (int)(l); i >= (int)(1); i--)
    b[(i - 1) / 9 + 1] = b[(i - 1) / 9 + 1] * 10 + s[i] - '0';
  l = (l - 1) / 9 + 1;
  for (int i = (int)(1); i <= (int)(n); i++)
    if (R[i + 1] == 1)
      rem[i] = 0;
    else
      rem[i] = DIV(R[i + 1]);
  if (l != 0) return puts("0"), 0;
  f[0][0] = 1;
  int l = 0, pr = 0, su = 1;
  for (int i = (int)(1); i <= (int)(n); i++) {
    for (int j = (int)(0); j <= (int)(l + c[i]); j++) f[su][j] = 0;
    for (int j = (int)(0); j <= (int)(l); j++) {
      UPD(f[su][j], f[pr][j]);
      UPD(f[su][j + c[i] + 1], mo - f[pr][j]);
    }
    l += c[i];
    for (int j = (int)(1); j <= (int)(l); j++) UPD(f[su][j], f[su][j - 1]);
    int nl = max(0, (l - rem[i]) / R[i + 1]);
    for (int j = (int)(0); j <= (int)(nl); j++)
      if (j * R[i + 1] + rem[i] <= l)
        f[su][j] = f[su][j * R[i + 1] + rem[i]];
      else
        f[su][j] = 0;
    l = nl;
    swap(pr, su);
  }
  printf("%d\n", f[pr][0]);
}
