#include <bits/stdc++.h>
using namespace std;
int M;
int X[111], Y[111];
long long C[1011][1011];
long long dp[1011][1011];
void compute() {
  for (int i = 0; i < 1011; i++)
    for (int j = 0; j <= i; j++) {
      if (j == 0 || j == i)
        C[i][j] = 1;
      else
        C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007LL;
    }
}
int main() {
  cin >> M;
  for (int i = 0; i < M; i++) cin >> X[i];
  for (int i = 0; i < M; i++) cin >> Y[i];
  for (int i = 0; i < M - 1; i++) X[i + 1] += X[i];
  compute();
  dp[M][X[M - 1]] = 1;
  for (int i = M - 1; i >= 0; i--) {
    for (int j = 0; j <= X[i]; j++) {
      for (int k = 0; k <= Y[i]; k++) {
        if (j + k <= X[i])
          dp[i][j] =
              (dp[i][j] + dp[i + 1][j + k] * C[X[i] - j][k]) % 1000000007LL;
      }
    }
  }
  long long ans = dp[0][0];
  for (int i = 0; i < M - 1; i++)
    ans = (ans * C[X[i + 1]][X[i]]) % 1000000007LL;
  cout << (int)ans << endl;
  return 0;
}
