#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 50, M = 1e2 + 50;
const long long MOD = 1e9 + 7;
int n, tot, x[N], y[N];
long long C[N][N], f[M][N], fac[N], inv[N];
long long Pow(long long a, long long b, long long MOD) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res % MOD;
}
void init(int n = 1e3) {
  C[0][0] = fac[0] = 1;
  for (int i = 1; i <= n; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
  }
  for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % MOD;
  inv[n] = Pow(fac[n], MOD - 2, MOD);
  for (int i = n - 1; i; --i) inv[i] = inv[i + 1] * (i + 1) % MOD;
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", x + i), tot += x[i];
  for (int i = 1; i <= n; i++) scanf("%d", y + i);
  f[0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= tot; j++) {
      for (int k = 0; k <= y[i]; k++)
        if (j + x[i] - k >= 0)
          (f[i][j + x[i] - k] += f[i - 1][j] * C[j + x[i]][k] % MOD) %= MOD;
    }
  long long ans = f[n][0], cnt = 0;
  for (int i = 1; i <= n; i++) cnt += x[i], ans = ans * inv[x[i]] % MOD;
  printf("%lld\n", (ans * fac[cnt] % MOD + MOD) % MOD);
  return 0;
}
