#include <bits/stdc++.h>
using namespace std;
const int maxN = 105, maxS = 1005, mod = 1e9 + 7;
int comb[maxS][maxS], dp[maxN][maxS];
int x[maxN], y[maxN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    k += x[i];
  }
  for (int i = 0; i < n; i++) cin >> y[i];
  comb[0][0] = 1;
  for (int i = 1; i < maxS; i++) {
    comb[i][0] = comb[i][i] = 1;
    for (int j = 1; j < i; j++)
      comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % mod;
  }
  long long kol = 1, curr = k;
  for (int i = 0; i < n; i++) kol *= comb[curr][x[i]], curr -= x[i], kol %= mod;
  dp[n][0] = 1;
  for (int i = n - 1; i >= 0; i--)
    for (int j = 0; j < maxS; j++) {
      int now = j + x[i];
      dp[i][j] = 0;
      for (int k = 0; k <= min(now, y[i]); k++) {
        long long way =
            1LL * dp[i + 1][min(maxS - 1, now - k)] * comb[now][k] % mod;
        dp[i][j] += way, dp[i][j] %= mod;
      }
    }
  cout << 1LL * kol * dp[0][0] % mod << endl;
}
