#include <bits/stdc++.h>
using namespace std;
int f[1005], rf[1005];
const int MOD = 1e9 + 7;
int c(int n, int k) { return (long long)f[n] * rf[k] % MOD * rf[n - k] % MOD; }
int binPow(long long x, int p) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = ret * x % MOD;
    p >>= 1;
    x = x * x % MOD;
  }
  return (int)ret;
}
int n = 0, m;
int x[100], y[100];
int d[1005][1005] = {};
int main() {
  f[0] = 1;
  for (int i = 1; i < 1005; ++i) f[i] = (long long)f[i - 1] * i % MOD;
  for (int i = 0; i < (int)(1005); ++i) rf[i] = binPow(f[i], MOD - 2);
  scanf("%d", &m);
  for (int i = 0; i < (int)(m); ++i) scanf("%d", x + i), n += x[i];
  for (int i = 0; i < (int)(m); ++i) scanf("%d", y + i);
  long long ans = f[n];
  for (int i = 0; i < (int)(m); ++i) ans = ans * rf[x[i]] % MOD;
  d[0][0] = 1;
  for (int i = 0; i < (int)(m - 1); ++i)
    for (int j = 0; j < (int)(n + 1); ++j)
      if (d[i][j]) {
        int cnt = j + x[i];
        for (int k = max(0, cnt - y[i]); k <= cnt; ++k) {
          d[i + 1][k] = (d[i + 1][k] + (long long)d[i][j] * c(cnt, k)) % MOD;
        }
      }
  long long ans2 = 0;
  for (int i = y[m - 1] - x[m - 1]; i >= 0; --i)
    ans2 = (ans2 + d[m - 1][i]) % MOD;
  ans = ans * ans2 % MOD;
  printf("%d\n", (int)ans);
  return 0;
}
