#include <bits/stdc++.h>
using namespace std;
int X[101];
int Y[101];
int rY[101];
const int MOD = 1000000007;
int m;
int memo[101][1010];
int C[1010][1010];
void init() {
  C[0][0] = 1;
  for (int i = 1; i <= 1000; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= 1000; j++) {
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
    }
  }
}
int dp(int i, int l) {
  if (i >= m) return l == 0;
  if (l > rY[i]) return 0;
  if (memo[i][l] != -1) return memo[i][l];
  int ret = 0;
  for (int p = 0; p <= X[i]; p++) {
    int left = Y[i] - p;
    if (left > l) left = l;
    int take = 0;
    for (int t = 0; t <= left; t++) {
      take = (take + (long long)C[l][t] * dp(i + 1, l - t + X[i] - p)) % MOD;
    }
    ret = (ret + (long long)take * C[X[i]][p]) % MOD;
  }
  return memo[i][l] = ret;
}
int main() {
  init();
  scanf("%d", &m);
  long long ret = 1, sum = 0;
  bool ok = false;
  for (int i = 0; i < m; i++) {
    scanf("%d", X + i);
    sum += X[i];
    if (X[i] != 0) ok = true;
  }
  for (int i = 0; i < m; sum -= X[i], i++) {
    ret = (ret * C[sum][X[i]]) % MOD;
  }
  for (int i = 0; i < m; i++) scanf("%d", Y + i);
  if (!ok) {
    puts("0");
    return 0;
  }
  rY[m - 1] = Y[m - 1];
  for (int i = m - 2; i >= 0; i--) rY[i] = rY[i + 1] + Y[i];
  memset(memo, -1, sizeof(memo));
  ret = ret * dp(0, 0);
  ret %= MOD;
  printf("%d\n", (int)ret);
  return 0;
}
