#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
long long mul[1000009], inv[1000009];
long long dp[109][10009];
int m, x[109], y[109], sum[109];
void init() {
  mul[0] = 1;
  for (int i = 1; i < 1000009; i++) mul[i] = (mul[i - 1] * i) % mod;
  inv[0] = inv[1] = 1;
  for (int i = 2; i < 1000009; i++)
    inv[i] = (long long)(mod - mod / i) * inv[mod % i] % mod;
  for (int i = 1; i < 1000009; i++) inv[i] = (inv[i - 1] * inv[i]) % mod;
}
long long C(int n, int m) { return mul[n] * inv[m] % mod * inv[n - m] % mod; }
int main() {
  init();
  while (~scanf("%d", &m)) {
    sum[0] = 0;
    for (int i = 1; i <= m; i++) {
      scanf("%d", &x[i]);
      sum[i] = sum[i - 1] + x[i];
    }
    for (int i = 1; i <= m; i++) scanf("%d", &y[i]);
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for (int i = 1; i <= m; i++)
      for (int j = 0; j <= sum[i]; j++)
        for (int k = 0; k <= min(j, y[i]); k++) {
          dp[i][j] += dp[i - 1][j - k] * C(sum[i] - (j - k), k) % mod;
          dp[i][j] %= mod;
        }
    long long ans = dp[m][sum[m]] * mul[sum[m]] % mod;
    for (int i = 1; i <= m; i++) ans = ans * inv[x[i]] % mod;
    printf("%lld\n", ans);
  }
  return 0;
}
