#include <bits/stdc++.h>
using namespace std;
int f[110][10010], c[10010][110], x[110], y[110], sum[110], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
    sum[i] = sum[i - 1] + x[i];
  }
  for (int i = 1; i <= n; i++) scanf("%d", &y[i]);
  c[0][0] = 1;
  for (int i = 1; i <= sum[n]; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= min(100, i); j++)
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % 1000000007;
  }
  f[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= sum[i - 1]; j++)
      for (int k = 0; k <= y[i]; k++)
        f[i][j + x[i] - k] = (f[i][j + x[i] - k] +
                              f[i - 1][j] * 1ll * c[j + x[i]][k] % 1000000007) %
                             1000000007;
  }
  int num = 1;
  for (int i = 1; i <= n; i++)
    num = num * 1ll * c[sum[n] - sum[i - 1]][x[i]] % 1000000007;
  printf("%d\n", f[n][0] * 1ll * num % 1000000007);
}
