#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
const long long mod = 1e9 + 7;
long long fact[maxn + 5], inv[maxn + 5], x[maxn + 5], y[maxn + 5],
    sum[maxn + 5];
void init() {
  fact[0] = 1;
  for (long long i = 1; i <= maxn; i++) fact[i] = (fact[i - 1] * i) % mod;
  inv[1] = 1;
  for (long long i = 2; i <= maxn; i++)
    inv[i] = mod - mod / i * inv[mod % i] % mod;
  inv[0] = 1;
  for (long long i = 1; i <= maxn; i++) inv[i] *= inv[i - 1], inv[i] %= mod;
}
long long C(long long n, long long m) {
  return fact[n] * inv[m] % mod * inv[n - m] % mod;
}
long long dp[105][1005];
int main() {
  init();
  long long m;
  scanf("%lld", &m);
  for (long long i = 1; i <= m; i++)
    scanf("%lld", &x[i]), sum[i] = sum[i - 1] + x[i];
  for (long long i = 1; i <= m; i++) scanf("%lld", &y[i]);
  dp[0][0] = 1;
  for (long long i = 1; i <= m; i++)
    for (long long j = 0; j <= sum[i]; j++)
      for (long long k = 0; k <= min(j, y[i]); k++)
        dp[i][j] += dp[i - 1][j - k] * C(sum[i] - (j - k), k), dp[i][j] %= mod;
  long long ans = dp[m][sum[m]];
  ans *= fact[sum[m]], ans %= mod;
  for (long long i = 1; i <= m; i++) ans *= inv[x[i]], ans %= mod;
  cout << ans << endl;
  return 0;
}
