#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000000 + 7;
const int M = 101, N = 1001;
long long dp[M][N];
long long x[M], y[M], sums[M];
long long newt[N][N];
int m;
long long binom(int n, int k) {
  if (k < 0 || k > n) return 0;
  if (k == 0 || k == n) return 1;
  if (newt[n][k] != -1) return newt[n][k];
  newt[n][k] = binom(n - 1, k - 1) + binom(n - 1, k);
  newt[n][k] %= mod;
  return newt[n][k];
}
long long solve(int i, int k) {
  if (k < 0) return 0;
  if (i == m) return k == 0;
  k += x[i];
  if (dp[i][k] != -1) return dp[i][k];
  long long res = 0;
  for (int a = 0; a <= y[i]; a++) {
    res += binom(k, a) * solve(i + 1, k - a);
    res %= mod;
  }
  return dp[i][k] = res;
}
long long fact[N];
struct t {
  long long x, y, d;
  t(long long a, long long b, long long c) {
    x = a;
    y = b;
    c = d;
  }
};
t eucl(long long a, long long b) {
  t tmp(0, 0, 0);
  if (a % b == 0) return t(0, 1, a);
  tmp = eucl(b, a % b);
  tmp.y %= mod;
  tmp.x %= mod;
  return t(tmp.y, tmp.x - tmp.y * (a / b), tmp.d);
}
long long inv(long long a, long long m) {
  t tmp = eucl(a, m);
  return tmp.x % mod;
}
int main() {
  scanf("%d", &m);
  int sum = 0;
  for (int i = 0; i < m; i++) {
    scanf("%lld", &x[i]);
    sum += x[i];
  }
  for (int i = 0; i < m; i++) {
    scanf("%lld", &y[i]);
  }
  sums[m - 1] = y[m - 1];
  for (int i = m - 2; i >= 0; i--) {
    sums[i] = sums[i + 1] + y[i];
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j <= sum; j++) {
      dp[i][j] = -1;
    }
  }
  for (int i = 0; i <= sum; i++) {
    for (int j = 0; j <= sum; j++) newt[i][j] = -1;
  }
  long long res = solve(0, 0);
  long long denom = 1;
  fact[0] = 1;
  for (int i = 1; i <= sum; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= mod;
  }
  res *= fact[sum];
  res %= mod;
  for (int i = 0; i < m; i++) {
    denom *= fact[x[i]];
    denom %= mod;
  }
  res *= inv(denom, mod);
  res %= mod;
  res += mod;
  res %= mod;
  printf("%lld\n", res);
}
