#include <bits/stdc++.h>
using namespace std;
const int MAX_M = 110;
const int MAX_N = 1e3 + 10;
const int MOD = 1e9 + 7;
int cnt[MAX_M], X[MAX_M], Y[MAX_M];
int m, n = 0;
long long cg = 1, dp[MAX_M][MAX_N], c[MAX_M][MAX_N];
int main() {
  for (int i = 0; i < MAX_M; i++)
    for (int j = 0; j < MAX_N; j++) c[i][j] = 0;
  for (int i = 0; i < MAX_N; i++) c[0][i] = 1;
  for (int i = 1; i < MAX_N; i++)
    for (int j = 1; j < min(MAX_M, i + 1); j++)
      c[j][i] = (c[j - 1][i - 1] + c[j][i - 1]) % MOD;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d", &X[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &Y[i]);
  for (int i = 1; i <= m; i++) cnt[i] = X[i] + cnt[i - 1];
  n = cnt[m];
  int sum = n;
  for (int i = 1; i <= m; i++) {
    cg = (cg * c[X[i]][sum]) % MOD;
    sum -= X[i];
  }
  dp[0][0] = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= cnt[i]; j++) {
      for (int k = 0; k <= Y[i]; k++) {
        if (j >= k) {
          dp[i][j] =
              (dp[i][j] + (dp[i - 1][j - k] * c[k][cnt[i] - j + k]) % MOD) %
              MOD;
        } else
          break;
      }
    }
  }
  printf("%d", (dp[m][n] * cg) % MOD);
  return 0;
}
