#include <bits/stdc++.h>
using namespace std;
int X[110], Y[110];
long long dp[110][1010];
long long C[1010][1010];
int main(void) {
  int M, i, j, k;
  scanf("%d", &M);
  for ((i) = 0; (i) < (int)(M); (i)++) scanf("%d", &X[i]);
  for ((i) = 0; (i) < (int)(M); (i)++) scanf("%d", &Y[i]);
  for ((i) = 0; (i) < (int)(M - 1); (i)++) X[i + 1] += X[i];
  for ((i) = 0; (i) < (int)(1010); (i)++)
    for ((j) = 0; (j) < (int)(i + 1); (j)++) {
      if (j == 0 || j == i)
        C[i][j] = 1;
      else
        C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007ll;
    }
  dp[M][X[M - 1]] = 1;
  for (i = M - 1; i >= 0; i--)
    for ((j) = 0; (j) < (int)(X[i] + 1); (j)++) {
      for ((k) = 0; (k) < (int)(Y[i] + 1); (k)++)
        if (k <= X[i] - j)
          dp[i][j] =
              (dp[i][j] + dp[i + 1][j + k] * C[X[i] - j][k]) % 1000000007ll;
    }
  long long ans = dp[0][0];
  for ((i) = 0; (i) < (int)(M - 1); (i)++)
    ans = ans * C[X[i + 1]][X[i]] % 1000000007ll;
  printf("%d\n", (int)ans);
  return 0;
}
