#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int C[N][N], dp[N][N];
int main() {
  int m, x[110], y[110], sum[110];
  sum[0] = 0;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", x + i);
    sum[i] = sum[i - 1] + x[i];
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", y + i);
  }
  C[0][0] = 1;
  for (int i = 1; i <= sum[m]; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007;
    }
  }
  dp[0][0] = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= sum[i]; j++) {
      for (int k = 0; k <= min(y[i], j); k++) {
        dp[i][j] =
            (dp[i][j] + (long long)dp[i - 1][j - k] * C[sum[i] - (j - k)][k]) %
            1000000007;
      }
    }
  }
  long long ans = dp[m][sum[m]] % 1000000007;
  for (int i = 1; i <= m; i++) {
    ans = (long long)(ans * C[sum[m] - sum[i - 1]][x[i]]) % 1000000007;
  }
  printf("%d\n", ans);
  return 0;
}
