#include <bits/stdc++.h>
using namespace std;
const int Maxn = 110;
const long long mod = 1000000007;
long long f[Maxn][Maxn * 10];
long long C[Maxn * 10][Maxn * 10];
int main() {
  int n;
  long long ans = 1;
  int x[Maxn], y[Maxn], sx[Maxn];
  cin >> n;
  sx[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    sx[i + 1] = sx[i] + x[i];
  }
  for (int i = 0; i < n; i++) cin >> y[i];
  for (int i = 0; i < Maxn * 10; 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;
  }
  for (int i = 0; i < n; i++) ans = ans * C[sx[n] - sx[i]][x[i]] % mod;
  f[0][0] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= sx[i]; j++)
      if (f[i][j] > 0) {
        int t = sx[i + 1] - j;
        for (int k = 0; k <= t && k <= y[i]; k++)
          f[i + 1][j + k] = (f[i + 1][j + k] + f[i][j] * C[t][k]) % mod;
      }
  ans = ans * f[n][sx[n]] % mod;
  cout << ans << endl;
  return 0;
}
