#include <bits/stdc++.h>
using namespace std;
long long dp[110][10010];
int a[110];
int b[110];
int sum[110];
long long c[10010][110];
void init() {
  for (int i = 1; i <= 10000; i++)
    for (int j = 0; j <= 100; j++) {
      if (j == 0 || j == i)
        c[i][j] = 1;
      else
        c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 1000000007LL;
    }
}
int main() {
  init();
  int n;
  cin >> n;
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  long long add = 1;
  int total = sum[n];
  for (int i = 1; i <= n; i++) {
    add = (add * c[total][a[i]]) % 1000000007LL;
    total -= a[i];
  }
  for (int i = 1; i <= n; i++) cin >> b[i];
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i <= a[1]; i++) dp[1][i] = c[a[1]][i];
  for (int i = 2; i <= n; i++)
    for (int j = a[i]; j <= sum[i]; j++) {
      if (dp[i - 1][j - a[i]] == 0) continue;
      for (int k = 0; k <= j && k <= b[i]; k++)
        dp[i][j - k] =
            (dp[i][j - k] + dp[i - 1][j - a[i]] * c[j][k]) % 1000000007LL;
    }
  dp[n][0] = (dp[n][0] * add) % 1000000007LL;
  cout << dp[n][0] << endl;
  return 0;
}
