#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()

#define int long long

signed main(){
  int n;cin>>n;
  vector<int> x(n),y(n);
  REP(i,n)cin>>x[i]>>y[i];
  int m;cin>>m;
  vector<int> a(m+1),b(m+1),c(m+1),d(m+1),e(m+1),f(m+1);
  a[0]=e[0]=1;
  b[0]=c[0]=d[0]=f[0]=0;
  REP(i,m){
    int t;cin>>t;
    a[i+1]=a[i],b[i+1]=b[i],c[i+1]=c[i],d[i+1]=d[i],e[i+1]=e[i],f[i+1]=f[i];
    if(t==1){
      a[i+1]=d[i],b[i+1]=e[i],c[i+1]=f[i];
      d[i+1]=-a[i],e[i+1]=-b[i],f[i+1]=-c[i];
    }
    if(t==2){
      a[i+1]=-d[i],b[i+1]=-e[i],c[i+1]=-f[i];
      d[i+1]=a[i],e[i+1]=b[i],f[i+1]=c[i];
    }
    if(t==3){
      int p;cin>>p;
      a[i+1]=-a[i],b[i+1]=-b[i],c[i+1]=2*p-c[i];
    }
    if(t==4){
      int p;cin>>p;
      d[i+1]=-d[i],e[i+1]=-e[i],f[i+1]=2*p-f[i];
    }
  }
  int q;cin>>q;
  REP(i,q){
    int A,B;cin>>A>>B;B--;
    cout<<a[A]*x[B]+b[A]*y[B]+c[A]<<" "<<d[A]*x[B]+e[A]*y[B]+f[A]<<endl;
  }
}

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
#define Type int
#define rept(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) rept(i,0,a)
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
vector<int>v[200005];
int sm[200005];
int c[200005];
signed main()
{
	int n,m;
	cin>>n>>m;
	rep(i,n) cin>>c[i],sm[i]=1000000000000000;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		v[b-1].pb(a-1);
	}
	int ans=-1000000000000000;
	rep(i,n){
		rep(j,sz(v[i])){
			sm[i]=min(sm[i],sm[v[i][j]]);
			sm[i]=min(sm[i],c[v[i][j]]);
		}
	//	cout<<sm[i]<<' ';
		ans=max(ans,c[i]-sm[i]);
	}
	cout<<ans;
	re 0;
}
