#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000000 + 7;
const int MAXM = 100 + 5;
const int MAXN = 1000 + 5;
int N, M;
int x[MAXM], y[MAXM];
long long memo1[100 + 5][100 * 100 * 2];
long long choose(int k, int n) {
  if (k == 0) return 1;
  if (n <= 0) return 0;
  long long &res = memo1[k][n];
  if (res != -1) return res;
  res = choose(k, n - 1) + choose(k - 1, n - 1);
  res = res % MOD;
  return res;
}
long long memo2[100 + 5][100 * 100 + 5];
long long f(int n, int carry, int left) {
  if (n == M) return carry == 0 ? 1 : 0;
  long long &res = memo2[n][carry];
  if (res != -1) return res;
  res = 0;
  for (int i = 0; i <= y[n]; i++) {
    res = (res +
           (choose(i, carry + x[n]) * f(n + 1, carry + x[n] - i, left - x[n])) %
               MOD) %
          MOD;
  }
  res = (res * choose(x[n], left)) % MOD;
  return res;
}
int main() {
  scanf("%d", &M);
  memset(memo1, -1, sizeof(memo1));
  memset(memo2, -1, sizeof(memo2));
  N = 0;
  for (int i = 0; i < M; i++) {
    scanf("%d", &x[i]);
    N += x[i];
  }
  for (int i = 0; i < M; i++) scanf("%d", &y[i]);
  printf("%lld\n", f(0, 0, N));
}
