#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long K(long long x, long long y = mod - 2) {
  long long t = 1;
  for (; y; y >>= 1, x = x * x % mod)
    if (y & 1) t = t * x % mod;
  return t;
}
long long jc(long long n) {
  long long t = 1;
  for (int i = 1; i <= n; ++i) t = t * i % mod;
  return t;
}
int C[1010][1010];
void PRE(int n) {
  for (int i = 0; i <= n; ++i) {
    C[i][0] = 1;
    for (int j = 1; j <= i; ++j)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  }
}
void U(int &x, int y) { x = (x + y) % mod; }
int n, m, a[111], b[111], f[1111], g[1111];
int main() {
  PRE(1001);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], m += a[i];
  for (int i = 1; i <= n; ++i) cin >> b[i];
  f[0] = 1;
  for (int t = 1; t <= n; ++t) {
    memset(g, 0, sizeof g);
    for (int i = 0; i <= m; ++i)
      if (f[i]) {
        for (int j = 0; j <= b[t] && j <= i + a[t]; ++j)
          U(g[i + a[t] - j], (long long)f[i] * C[i + a[t]][j] % mod);
      }
    swap(f, g);
  }
  long long ans = f[0] * jc(m) % mod;
  for (int i = 1; i <= n; ++i) ans = ans * K(jc(a[i])) % mod;
  cout << ans << endl;
}
