Problem: There are n types of coins in Byteland. Conveniently, the denomination of the coin type k divides the denomination of the coin type k + 1, the denomination of the coin type 1 equals 1 tugrick. The ratio of the denominations of coin types k + 1 and k equals ak. It is known that for each x there are at most 20 coin types of denomination x.

Byteasar has bk coins of type k with him, and he needs to pay exactly m tugricks. It is known that Byteasar never has more than 3·105 coins with him. Byteasar want to know how many ways there are to pay exactly m tugricks. Two ways are different if there is an integer k such that the amount of coins of type k differs in these two ways. As all Byteland citizens, Byteasar wants to know the number of ways modulo 109 + 7.

Input

The first line contains single integer n (1 ≤ n ≤ 3·105) — the number of coin types.

The second line contains n - 1 integers a1, a2, ..., an - 1 (1 ≤ ak ≤ 109) — the ratios between the coin types denominations. It is guaranteed that for each x there are at most 20 coin types of denomination x.

The third line contains n non-negative integers b1, b2, ..., bn — the number of coins of each type Byteasar has. It is guaranteed that the sum of these integers doesn't exceed 3·105.

The fourth line contains single integer m (0 ≤ m < 1010000) — the amount in tugricks Byteasar needs to pay.

Output

Print single integer — the number of ways to pay exactly m tugricks modulo 109 + 7.

Examples

Input

1

4
2


Output

1


Input

2
1
4 4
2


Output

3


Input

3
3 3
10 10 10
17


Output

6

Note

In the first example Byteasar has 4 coins of denomination 1, and he has to pay 2 tugricks. There is only one way.

In the second example Byteasar has 4 coins of each of two different types of denomination 1, he has to pay 2 tugricks. There are 3 ways: pay one coin of the first type and one coin of the other, pay two coins of the first type, and pay two coins of the second type.

In the third example the denominations are equal to 1, 3, 9.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
template <class T>
inline T isqrt(T k) {
  T r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
template <class T>
inline T icbrt(T k) {
  T r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(long double x, long double y) { return sign(x - y); }
const int BASE = 1000000000;
const int NBLOCK = 9;
struct Bigint {
  vector<int> data;
  Bigint() { data.push_back(0); }
  Bigint(long long x) {
    if (!x) data.push_back(0);
    while (x) data.push_back(x % BASE), x /= BASE;
  }
  Bigint(string s);
  void trim() {
    while (data.size() > 1 && !data.back()) data.pop_back();
  }
  int& operator[](int i) { return data[i]; }
  int len() { return data.size(); }
  int iszero() const { return data.empty() || (data.size() == 1 && !data[0]); }
  long long longValue() const {
    long long res = 0;
    for (int i = data.size() - 1; i >= 0; i--) res = res * BASE + data[i];
    return res;
  }
};
Bigint::Bigint(string s) {
  data.clear();
  int pos = 0;
  for (int i = s.size() - 1; i >= pos; i -= NBLOCK) {
    int x = 0;
    for (int j = max(pos, i - NBLOCK + 1); j <= i; j++) x = x * 10 + s[j] - '0';
    data.push_back(x);
  }
  trim();
}
pair<Bigint, int> divmod(Bigint a, int m) {
  long long r = 0;
  for (int i = a.len() - 1; i >= 0; i--) {
    r = r * BASE + a[i];
    a[i] = r / m;
    r %= m;
  }
  a.trim();
  return make_pair(a, (int)r);
}
const int maxn = 300000 + 5;
int n;
int a[maxn];
int b[maxn];
int c[maxn];
int dp[maxn];
int ff[maxn];
void solve() {
  cin >> n;
  for (int i = (0); i < (n - 1); i++) cin >> a[i];
  for (int i = (0); i < (n); i++) cin >> b[i];
  string s;
  cin >> s;
  Bigint m(s);
  for (int i = (0); i < (n - 1); i++) {
    if (a[i] > 1) {
      pair<Bigint, Bigint> r = divmod(m, a[i]);
      c[i] = r.second.longValue();
      m = r.first;
    }
  }
  for (int i = (0); i < (b[0] + 1); i++) dp[i] = 1;
  int pv = b[0];
  for (int i = (1); i < (n); i++) {
    int cr = pv / a[i - 1] + b[i];
    for (int j = (0); j < (pv + 1); j++) {
      if (j >= a[i - 1]) {
        addmod(dp[j], dp[j - a[i - 1]]);
      }
    }
    for (int j = (0); j < (cr + 1); j++) {
      long long lo = (long long)(j - min(j, b[i])) * a[i - 1] + c[i - 1];
      long long hi = min((long long)pv, (long long)j * a[i - 1] + c[i - 1]);
      c[i - 1] %= a[i - 1];
      if (lo <= hi && hi >= c[i - 1]) {
        hi = (hi - c[i - 1]) / a[i - 1] * a[i - 1] + c[i - 1];
        if (lo < c[i - 1]) {
          lo = c[i - 1];
        } else {
          lo = (lo - c[i - 1] + a[i - 1] - 1) / a[i - 1] * a[i - 1] + c[i - 1];
        }
        if (lo <= hi) {
          ff[j] = dp[hi];
          if (lo >= a[i - 1]) {
            submod(ff[j], dp[lo - a[i - 1]]);
          }
        }
      }
    }
    for (int j = (0); j < (cr + 1); j++) {
      dp[j] = ff[j];
      ff[j] = 0;
    }
    pv = cr;
  }
  if (int((m.data).size()) >= 10 || m.longValue() > pv) {
    cout << 0 << "\n";
  } else {
    cout << dp[m.longValue()] << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}