#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int maxn = 1010;
const int mod = 1000000007;
int a[maxn], b[maxn];
long long dp[110][maxn], sum[maxn], C[maxn][maxn];
int main() {
  ios::sync_with_stdio(false);
  C[0][0] = 1;
  for (int i = 1; i <= 1000; 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;
    }
  }
  int n;
  long long ans = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= sum[i]; j++) {
      if (i == 1)
        dp[i][j] = C[sum[1]][j];
      else {
        for (int k = max(0, a[i] - j); k <= b[i]; k++) {
          dp[i][j] =
              (dp[i][j] + dp[i - 1][j + k - a[i]] * C[j + k][k] % mod) % mod;
        }
      }
    }
  }
  ans = dp[n][0];
  for (int i = n; i >= 1; i--) {
    ans = (ans * C[sum[i]][a[i]]) % mod;
  }
  cout << ans << "\n";
  return 0;
}
