#include <bits/stdc++.h>
using namespace std;
const int N = 1010, M = 110, mo = 1e9 + 7;
int n, a[N], b[N], s[N];
long long C[N][N], dp[M][N], fac[N], inv[N];
long long ksm(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return ans;
}
long long ans;
int main() {
  scanf("%d", &n);
  fac[0] = ans = 1;
  for (int i = 1; i < N; ++i) fac[i] = fac[i - 1] * i % mo;
  inv[N - 1] = ksm(fac[N - 1], mo - 2);
  for (int i = N - 2; i >= 0; --i) inv[i] = inv[i + 1] * (i + 1) % mo;
  C[0][0] = 1;
  for (int i = 1; i < N; ++i) {
    C[i][0] = 1;
    for (int j = 1; j < N; ++j) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mo;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    s[i] = s[i - 1] + a[i];
    ans = (ans * inv[a[i]]) % mo;
  }
  ans = ans * fac[s[n]] % mo;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &b[i]);
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j <= s[i - 1]; ++j) {
      for (int k = 0; k <= min(j + a[i], b[i]); ++k)
        (dp[i][j + a[i] - k] += dp[i - 1][j] * C[j + a[i]][k] % mo) %= mo;
    }
  printf("%d\n", dp[n][0] * ans % mo);
}
