#include <bits/stdc++.h>
using namespace std;
int ans = 1, n, m, sum[110], num1[110], num2[110], fac[10010], inv[10010],
    f[110][10010];
int C(int n, int m) {
  return 1ll * fac[n] * inv[m] % 1000000007 * inv[n - m] % 1000000007;
}
int qpow(int x, int y) {
  int tmp = 1;
  while (y) {
    if (y & 1) tmp = 1ll * tmp * x % 1000000007;
    y >>= 1, x = 1ll * x * x % 1000000007;
  }
  return tmp;
}
int main() {
  scanf("%d", &m), f[0][0] = 1;
  for (int i = 1; i <= m; i++) scanf("%d", &num1[i]), n += num1[i];
  for (int i = 1; i <= m; i++)
    scanf("%d", &num2[i]), sum[i] = sum[i - 1] + num1[i];
  for (int i = fac[0] = 1; i <= n; i++)
    fac[i] = 1ll * fac[i - 1] * i % 1000000007;
  for (int i = inv[0] = 1; i <= n; i++) inv[i] = qpow(fac[i], 1000000007 - 2);
  for (int i = 1; i <= m; i++)
    ans = 1ll * ans * C(n, num1[i]) % 1000000007, n -= num1[i];
  for (int i = 1; i <= m; i++)
    for (int j = 0; j <= sum[i]; j++)
      for (int k = 0; k <= min(num2[i], sum[i] - j); k++)
        (f[i][j + k] += 1ll * f[i - 1][j] * C(sum[i] - j, k) % 1000000007) %=
            1000000007;
  ans = 1ll * ans * f[m][sum[m]] % 1000000007, printf("%d\n", ans);
}
