#include #include using namespace std; using ll=long long; using ull=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) using mll = atcoder::static_modint<1000000007>; int Q; vector A,B; int main(){ scanf("%d",&Q); A.resize(Q+1); rep(i,Q) scanf("%d",&A[i+1]); B.resize(Q+1); rep(i,Q) scanf("%d",&B[i+1]); for(int i=1; i<=Q; i++){ mll ans=1; for(int i2=1; i2<=A[i]; i2++){ mll sum=0; for(int j=1; j<=B[i2]; j++){ sum += mll(j).pow(i2); } ans *= sum; } printf("%u\n",ans.val()); } return 0; }