#include <bits/stdc++.h>
using namespace std;
int mmod = 1000000007;
int comb[1001][1001];
long long cnt[101][1001] = {0};
int combi(int a, int b) {
  if (b < 0 || b > a) return 0;
  return comb[a][b];
}
void make_combi() {
  comb[0][0] = 1;
  for (int i = 1; i <= 1000; i++) {
    for (int j = 0; j < i; j++) {
      comb[i][j] += comb[i - 1][j];
      comb[i][j + 1] += comb[i - 1][j];
    }
    for (int j = 0; j <= i; j++) comb[i][j] %= mmod;
  }
}
int main() {
  make_combi();
  int m;
  scanf("%d", &m);
  int x[100], y[100];
  for (int i = 0; i < m; i++) scanf("%d", &x[i]);
  for (int i = 0; i < m; i++) scanf("%d", &y[i]);
  long long ans = 1;
  int sum = 0;
  for (int i = 0; i < m; i++) sum += x[i];
  {
    cnt[0][0] = 1;
    for (int j = 1; j <= m; j++) {
      for (int k = 0; k <= sum; k++) {
        cnt[j][k] = 0;
        for (int l = 0; l <= sum; l++)
          if (l + x[j - 1] - k <= y[j - 1]) {
            cnt[j][k] = (cnt[j][k] + cnt[j - 1][l] * combi(l + x[j - 1],
                                                           l + x[j - 1] - k)) %
                        mmod;
          }
      }
    }
    ans = cnt[m][0];
  }
  for (int i = 0; i < m; i++) {
    ans = (ans * combi(sum, x[i])) % mmod;
    sum -= x[i];
  }
  printf("%d\n", (int)ans);
  return 0;
}
