#include <bits/stdc++.h>
bool debug = false;
using namespace std;
long long convertToNum(string s) {
  long long val = 0;
  for (int i = 0; i < (s.size()); i++) val = val * 10 + s[i] - '0';
  return val;
}
string convertToString(long long a) {
  string res = "";
  if (!a) return "0";
  while (a) {
    res = (char)(a % 10 + 48) + res;
    a /= 10;
  }
  return res;
}
long long GCD(long long x, long long y) {
  if (!x) return y;
  if (!y) return x;
  if (x == y) return x;
  if (x < y)
    return GCD(x, y % x);
  else
    return GCD(x % y, y);
}
long long POW(long long x, long long y, long long Base) {
  if (!y) return 1;
  long long u = POW(x, y / 2, Base);
  u = (u * u) % Base;
  if (y & 1)
    return (u * x) % Base;
  else
    return u;
}
const int Dice[24][6] = {
    {1, 2, 3, 4, 5, 6}, {1, 6, 3, 5, 2, 4}, {1, 4, 3, 2, 6, 5},
    {1, 5, 3, 6, 4, 2}, {2, 1, 4, 3, 6, 5}, {6, 1, 5, 3, 4, 2},
    {5, 1, 6, 3, 2, 4}, {4, 1, 2, 3, 5, 6}, {3, 2, 1, 4, 6, 5},
    {3, 5, 1, 6, 2, 4}, {3, 4, 1, 2, 5, 6}, {3, 6, 1, 5, 4, 2},
    {2, 3, 4, 1, 5, 6}, {4, 3, 2, 1, 6, 5}, {5, 3, 6, 1, 4, 2},
    {6, 3, 5, 1, 2, 4}, {2, 5, 4, 6, 1, 3}, {4, 6, 2, 5, 1, 3},
    {5, 4, 6, 2, 1, 3}, {6, 2, 5, 4, 1, 3}, {2, 6, 4, 5, 3, 1},
    {4, 5, 2, 6, 3, 1}, {5, 2, 6, 4, 3, 1}, {6, 4, 5, 2, 3, 1}};
int m, n;
int x[1004], y[1004], s[1004];
long long F[104][1004], C[1004][1004];
long long Base = 1000000007;
int main() {
  cin >> m;
  for (int i = (1); i <= (m); i++)
    cin >> x[i], n += x[i], s[i] = s[i - 1] + x[i];
  for (int i = (1); i <= (m); i++) cin >> y[i];
  C[0][0] = 1;
  for (int i = (1); i <= (n); i++) C[0][i] = 1;
  for (int i = (1); i <= (n); i++)
    for (int j = (i); j <= (n); j++) {
      C[i][j] = C[i][j - 1] + C[i - 1][j - 1];
      if (C[i][j] >= Base) C[i][j] -= Base;
    }
  F[0][0] = 1;
  for (int i = (1); i <= (m); i++)
    for (int j = (0); j <= (s[i]); j++)
      for (int k = (0); k <= (min(j, y[i])); k++)
        F[i][j] = (F[i][j] + F[i - 1][j - k] * C[k][s[i] - (j - k)]) % Base;
  long long res = F[m][n];
  for (int i = (1); i <= (m); i++) {
    res = (res * C[x[i]][n]) % Base;
    n -= x[i];
  }
  cout << res << endl;
  return 0;
}
