#include <bits/stdc++.h>
using namespace std;
int x[110];
int y[110];
int d[110][2100];
int c[2010][2010];
int modd = 1000000007;
int sum[10010];
int main() {
  int n, ans = 0, schet = 0;
  cin >> n;
  for (int i = 0; i < 1001; i++) {
    c[i][i] = 1;
    c[i][0] = 1;
  }
  for (int i = 1; i <= 1000; i++)
    for (int j = 1; j < i; j++)
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % modd;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
    schet += x[i];
  }
  for (int i = 0; i < n; i++) scanf("%d", &y[i]);
  for (int i = n - 1; i >= 0; i--)
    if (i != n - 1)
      sum[i] = sum[i + 1] + x[i];
    else
      sum[i] = x[i];
  for (int i = x[0] + 1 - 1; i >= 0; i--) {
    if (i > y[0]) break;
    d[0][x[0] - i] += c[x[0]][i];
    d[0][x[0] - i] %= modd;
  }
  for (int i = 1; i < n; i++)
    for (int j = 0; j < 1010; j++)
      for (int z = 0; z < 1010; z++) {
        if (z > y[i]) break;
        if (j - x[i] + z < 0) continue;
        d[i][j] += (1ll * d[i - 1][j - x[i] + z] * c[j + z][z]) % modd;
        d[i][j] %= modd;
      }
  ans = d[n - 1][0];
  for (int i = 0; i < n; i++) ans = (1ll * ans * c[sum[i]][x[i]]) % modd;
  cout << ans;
  return 0;
}
