#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,dp[100005][2],a[100005],b[100005],ans = 0;
const ll mod = 1e9 + 7;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
memset(dp, 0, sizeof dp);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
for(int i = 2; i <= n; i++)
cin >> b[i];
dp[0][0] = 1;
dp[0][1] = 0;
for(int i = 1; i <= n; i++)
{
dp[i][0] = (dp[i-1][0]*(a[i] + b[i])%mod + dp[i-1][1]*(a[i]+b[i]-1)%mod)%mod;
dp[i][1] = (dp[i-1][0]*b[i]%mod + dp[i-1][1]*b[i+1]%mod)%mod;
cout << dp[i][0] << ' ' << dp[i][1] << '\n';
}
ans = dp[n][0] + dp[n][1];
ans%=mod;
cout << ans;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKbGwgbixkcFsxMDAwMDVdWzJdLGFbMTAwMDA1XSxiWzEwMDAwNV0sYW5zID0gMDsKY29uc3QgbGwgbW9kID0gMWU5ICsgNzsKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOyBjaW4udGllKDApOyBjb3V0LnRpZSgwKTsKICAgIG1lbXNldChkcCwgMCwgc2l6ZW9mIGRwKTsKICAgIGNpbiA+PiBuOwogICAgZm9yKGludCBpID0gMTsgaSA8PSBuOyBpKyspCiAgICAgICAgY2luID4+IGFbaV07CiAgICBmb3IoaW50IGkgPSAyOyBpIDw9IG47IGkrKykKICAgICAgICBjaW4gPj4gYltpXTsKICAgIGRwWzBdWzBdID0gMTsKICAgIGRwWzBdWzFdID0gMDsKICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKQogICAgewogICAgICAgIGRwW2ldWzBdID0gKGRwW2ktMV1bMF0qKGFbaV0gKyBiW2ldKSVtb2QgKyBkcFtpLTFdWzFdKihhW2ldK2JbaV0tMSklbW9kKSVtb2Q7CiAgICAgICAgZHBbaV1bMV0gPSAoZHBbaS0xXVswXSpiW2ldJW1vZCArIGRwW2ktMV1bMV0qYltpKzFdJW1vZCklbW9kOwogICAgICAgIGNvdXQgPDwgZHBbaV1bMF0gPDwgJyAnIDw8IGRwW2ldWzFdIDw8ICdcbic7CiAgICB9CiAgICBhbnMgPSBkcFtuXVswXSArIGRwW25dWzFdOwogICAgYW5zJT1tb2Q7CiAgICBjb3V0IDw8IGFuczsKfQo=