#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007;
int N, X[111], Y[111];
long long F[111][1111], C[1111][1111];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", &X[i]);
  for (int i = 1; i <= N; i++) scanf("%d", &Y[i]);
  for (int i = 1; i <= N; i++) X[i] += X[i - 1];
  for (int i = 0; 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]) % M;
  }
  F[0][0] = 1;
  for (int i = 1; i <= N; i++)
    for (int j = 0; j <= X[i]; j++) {
      for (int k = 0; k <= j; k++)
        if (j - k <= Y[i]) {
          F[i][j] = (F[i][j] + F[i - 1][k] * C[X[i] - k][j - k]) % M;
        }
    }
  long long Ret = F[N][X[N]];
  for (int i = 1; i <= N; i++)
    Ret = (Ret * C[X[N] - X[i - 1]][X[i] - X[i - 1]]) % M;
  printf("%I64d", Ret);
  return 0;
}
