#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define all(a) a.begin(), a.end()
using namespace std;
using P  = pair<int, int>;
using ll = long long;
using vi = vector<ll>;
using vv = vector<vi>;


int main(){
    int n;
    cin >> n;
    vv x(n, vi (3, 1));
    rep(i,n)cin >> x[i][0] >> x[i][1];
    int m;
    cin >> m;
    //affine transformation matrix
    vector<vv> amat(m+1, vv (3, vi (3, 0)));
    amat[0][0][0] = 1;
    amat[0][1][1] = 1;
    amat[0][2][2] = 1;
    rep(mm,m){
        int op;
        cin >> op;
        vv b(3, vi (3, 0));
        if(op==1){//clock
            b[0][1] = 1;
            b[1][0] = -1;
            b[2][2] = 1;
        }else if(op==2){//anticlock
            b[0][1] = -1;
            b[1][0] = 1;
            b[2][2] = 1;
        }else{
            ll p;
            cin >> p;
            if(op==3){
                b[0][0] = -1;
                b[0][2] = p*2;
                b[1][1] = 1;
                b[2][2] = 1;
            }else{
                b[0][0] = 1;
                b[1][2] = p*2;
                b[1][1] = -1;
                b[2][2] = 1;
            }
        }
        rep(i,3)rep(j,3){
            rep(k,3)amat[mm+1][i][j] += b[i][k] * amat[mm][k][j];
        }
    }
    
    int q;
    cin >> q;
    rep(qq,q){
        int a, koma;
        cin >> a >> koma;
        koma--;
        vi ans(3, 0);
        rep(i,2)rep(k,3)ans[i] += amat[a][i][k]*x[koma][k];
        cout << ans[0] << " " << ans[1] << endl;
    }
    
    return 0;
}
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll a[maxn],b[maxn],c[maxn],n;

int main()
{
	n=read(); rep(i,1,n) a[i]=read(); rep(i,1,n) b[i]=read();
	ll premax=0,ans=0;
	rep(i,1,n)
	{
		premax=max(premax,a[i]);
		c[i]=max(c[i-1],premax*b[i]);
	}
	rep(i,1,n) printf("%lld\n",c[i]);
	return 0;
}