#include <bits/stdc++.h>
using namespace std;
int a1[200], a2[200];
int d[2][10000];
int c[1010][1010];
int main() {
  int i, j, k, tmp, n, tot, now;
  scanf("%d", &n);
  tot = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &a1[i]);
    tot += a1[i];
  }
  for (i = 0; i < n; i++) scanf("%d", &a2[i]);
  for (i = 0; i <= tot; i++) {
    c[i][0] = 1;
    c[i][i] = 1;
    for (j = 1; j < i; j++) {
      c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
      if (c[i][j] >= 1000000007) c[i][j] -= 1000000007;
    }
  }
  memset(d, 0, sizeof(d));
  d[0][0] = 1;
  now = 0;
  for (i = 0; i < n; i++) {
    memset(d[1 - now], 0, sizeof(d[1 - now]));
    for (j = 0; j <= tot; j++)
      if (d[now][j] != 0) {
        tmp = j + a1[i];
        for (k = 0; k <= tmp && k <= a2[i]; k++) {
          d[1 - now][tmp - k] += (long long)d[now][j] * c[tmp][k] % 1000000007;
          if (d[1 - now][tmp - k] >= 1000000007)
            d[1 - now][tmp - k] -= 1000000007;
        }
      }
    now = 1 - now;
  }
  for (i = 0; i < n; i++) {
    d[now][0] = (long long)d[now][0] * c[tot][a1[i]] % 1000000007;
    tot -= a1[i];
  }
  printf("%d\n", d[now][0]);
  return 0;
}
