#include <bits/stdc++.h>
using namespace std;
long long int modulo = 1000000007;
struct entero {
  long long int x;
  entero() { x = 0; }
  entero(long long int xin) { x = xin % modulo; }
};
entero operator+(entero e1, entero e2) {
  return entero((e1.x + e2.x) % modulo);
}
entero operator*(entero e1, entero e2) {
  return entero((e1.x * e2.x) % modulo);
}
bool operator!=(entero e1, entero e2) { return e1.x != e2.x; }
entero memcombi[1001][1001];
entero combinatori(int n, int k) {
  if (k == 0 or n == k) return 1;
  entero &m = memcombi[n][k];
  if (m.x != -1) return m;
  m = combinatori(n - 1, k - 1) + combinatori(n - 1, k);
  return m;
}
entero memoria[100][1001];
int n;
vector<int> x;
vector<int> y;
entero calcula(int pos, int acum) {
  if (pos == n) {
    if (acum > 0) return 0;
    return 1;
  }
  entero &m = memoria[pos][acum];
  if (m != -1) return m;
  m = 0;
  int n = acum + x[pos];
  for (int k = 0; k <= n and k <= y[pos]; k++)
    m = m + combinatori(n, k) * calcula(pos + 1, n - k);
  return m;
}
entero particiones() {
  int s = 0;
  for (int i = 0; i < n; i++) s += x[i];
  entero p = 1;
  for (int i = 0; i < n; i++) {
    p = p * combinatori(s, x[i]);
    s -= x[i];
  }
  return p;
}
int main() {
  for (int i1 = 0; i1 < 1001; i1++)
    for (int i2 = 0; i2 < 1001; i2++) memcombi[i1][i2] = -1;
  for (int i1 = 0; i1 < 100; i1++)
    for (int i2 = 0; i2 < 1001; i2++) memoria[i1][i2] = -1;
  cin >> n;
  x = vector<int>(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  y = vector<int>(n);
  for (int i = 0; i < n; i++) cin >> y[i];
  cout << (particiones() * calcula(0, 0)).x << endl;
}
