#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int N = 10010;
int fac[N], inv[N];
int m, x[N >> 4], f[N >> 4][N];
int c(int x, int y) {
  if (x < y) return 0;
  return (long long)fac[x] * inv[x - y] % M * inv[y] % M;
}
int fp(int x, int y) {
  int ret = 1;
  for (; y; y >>= 1, x = (long long)x * x % M)
    if (y & 1) ret = (long long)ret * x % M;
  return ret;
}
int main() {
  scanf("%d", &m);
  fac[0] = 1;
  for (int i = 1; i <= 10000; ++i) fac[i] = (long long)fac[i - 1] * i % M;
  inv[10000] = fp(fac[10000], M - 2);
  for (int i = 9999; i >= 0; --i) inv[i] = (long long)inv[i + 1] * (i + 1) % M;
  int ans = 1;
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &x[i]);
    ans = (long long)ans * inv[x[i]] % M;
    x[i] += x[i - 1];
  }
  ans = (long long)ans * fac[x[m]] % M;
  f[0][0] = 1;
  for (int i = 1; i <= m; ++i) {
    int y;
    scanf("%d", &y);
    for (int j = 0; j <= x[i]; ++j) {
      for (int k = 0; k <= y && k <= j; ++k) {
        f[i][j] =
            (f[i][j] + (long long)f[i - 1][j - k] * c(x[i] - j + k, k)) % M;
      }
    }
  }
  cout << (long long)f[m][x[m]] * ans % M;
}
