#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
const int Mod = 1e9 + 7;
int add(int a, int b) { return (a += b) >= Mod ? a - Mod : a; }
int mul(int a, int b) { return 1ll * a * b % Mod; }
int m, n = 0, x[N], y[N];
int dp[N][N], c[N][N];
void init() {
  for (int i = 0; i < N; i++) c[i][0] = 1;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= i; j++) {
      c[i][j] = add(c[i - 1][j - 1], c[i - 1][j]);
    }
  }
}
int main() {
  init();
  scanf("%d", &m);
  dp[0][0] = 1;
  for (int i = 1; i <= m; i++) scanf("%d", &x[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &y[i]);
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= n; j++)
      if (dp[i - 1][j])
        for (int k = 0; k <= min(y[i], j + x[i]); k++)
          dp[i][x[i] + j - k] =
              add(dp[i][x[i] + j - k], mul(dp[i - 1][j], c[j + x[i]][k]));
    n += x[i];
  }
  int ans = dp[m][0];
  for (int i = 1; i <= m; i++) {
    ans = mul(ans, c[n][x[i]]);
    n -= x[i];
  }
  printf("%d", ans);
  return 0;
}
