#include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int M = 300005;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const long long oo = 0x3f3f3f3f3f3f3f3fll;
const double eps = 1e-6;
int n, first[N], second[N], sum[N];
long long dp[N][1010], c[1010][1010];
long long dfs(int a, int b) {
  if (a == n) {
    return b + first[n] <= second[n];
  }
  long long &ret = dp[a][b];
  if (ret + 1) return ret;
  ret = 0;
  for (int i = 0; i <= min(second[a], b + first[a]); i++) {
    ret = (ret + dfs(a + 1, b + first[a] - i) * c[b + first[a]][i] % mod) % mod;
  }
  (ret *= c[sum[a]][first[a]]) %= mod;
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &first[i]);
  for (int i = n; i >= 1; i--) sum[i] = sum[i + 1] + first[i];
  for (int i = 1; i <= n; i++) scanf("%d", &second[i]);
  long long ret = 1;
  for (int i = 0; i < 1010; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++) c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
  }
  memset(dp, -1, sizeof(dp));
  ret = dfs(1, 0);
  cout << ret << endl;
  return 0;
}
