#include <bits/stdc++.h>
using namespace std;
const int mo = 1e9 + 7;
int X[1200], Y[1200], C[1200][1200], i, j, k, m, n, f[1200][1200], ans;
int main() {
  scanf("%d", &m);
  for (i = 1; i <= m; ++i) scanf("%d", &X[i]), n += X[i];
  for (i = 1; i <= m; ++i) scanf("%d", &Y[i]);
  for (i = 0; i <= n; ++i)
    for (j = 0; j <= i; ++j)
      C[i][j] = !j ? 1 : (C[i - 1][j - 1] + C[i - 1][j]) % mo;
  f[0][0] = 1;
  for (i = 1; i <= m; ++i)
    for (j = 0; j <= n; ++j)
      for (k = 0; k <= Y[i]; ++k)
        if (j - X[i] + k >= 0)
          f[i][j] = (1ll * f[i - 1][j - X[i] + k] * C[j + k][k] + f[i][j]) % mo;
  ans = f[m][0];
  for (i = 1; i <= m; ++i) ans = 1ll * ans * C[n][X[i]] % mo, n -= X[i];
  printf("%d\n", ans);
}
