#include <bits/stdc++.h>
using namespace std;
int n, a[111], b[111], s, c[1010][111];
long long f[111][1010];
int main() {
  int i, j, k;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    s += a[i];
  }
  for (i = 1; i <= n; i++) cin >> b[i];
  for (i = 0; i <= s; i++) {
    c[i][0] = 1;
    c[i][i] = 1;
    for (j = 1; j <= min(i - 1, 100); j++) {
      c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
      if (c[i][j] >= 1000000007) c[i][j] -= 1000000007;
    }
  }
  for (j = 0; j <= a[1]; j++) f[1][j] = c[a[1]][j];
  s = a[1];
  for (i = 2; i <= n; i++) {
    for (j = 0; j <= b[i]; j++)
      for (k = 0; k <= s; k++)
        f[i][j + k] =
            (f[i][j + k] + f[i - 1][k] * c[s + a[i] - k][j]) % 1000000007;
    s += a[i];
  }
  long long re = f[n][s];
  for (i = 1; i <= n; i++) {
    re = (re * c[s][a[i]]) % 1000000007;
    s -= a[i];
  }
  cout << re << endl;
  return 0;
}
