#include <bits/stdc++.h>
#define N 200005
using namespace std;
using ll = long long;

struct point { ll x, y; };

struct matrix {
	ll mat[3][3];

	matrix operator*(matrix rhs) {
		matrix res;
		for (int i=0; i<3; i++) {
			for (int j=0; j<3; j++) {
				res.mat[i][j] = 0;
				for (int k=0; k<3; k++) {
					res.mat[i][j] += mat[i][k] * rhs.mat[k][j];
				}
			}
		}
		return res;
	}

	point operator*(point p) {
		return {
			mat[0][0]*p.x + mat[0][1]*p.y + mat[0][2],
			mat[1][0]*p.x + mat[1][1]*p.y + mat[1][2],
		};
	}

	void print() {
		for (int i=0; i<3; i++) {
			for (int j=0; j<3; j++) cout<<mat[i][j]<<' ';
			cout<<endl;
		}
		cout<<endl;
	}
};

matrix rot_cw() { return {0,1,0, -1,0,0, 0,0,1}; }
matrix rot_ccw() { return {0,-1,0, 1,0,0, 0,0,1}; }
matrix ref_x(ll k) { return {-1,0,2*k, 0,1,0, 0,0,1}; }
matrix ref_y(ll k) { return {1,0,0, 0,-1,2*k, 0,0,1}; }

int n, m, q;
point ps[N];
matrix pre[N];

int main() {
	cin>>n;
	for (int i=1; i<=n; i++) cin>>ps[i].x>>ps[i].y;

	cin>>m; pre[0] = {1,0,0, 0,1,0, 0,0,1};
	for (int i=1; i<=m; i++) {
		int t; cin>>t;
		if (t == 1) pre[i] = rot_cw();
		else if (t == 2) pre[i] = rot_ccw();
		else {
			int k; cin>>k;
			if (t == 3) pre[i] = ref_x(k);
			else pre[i] = ref_y(k);
		}
		pre[i] = pre[i] * pre[i-1];
	}

	cin>>q;
	while (q--) {
		int a, b; cin>>a>>b;
		point p = pre[a] * ps[b];
		cout<<p.x<<' '<<p.y<<endl;
	}
	
}

#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define sz(x)                 (int)(x).size()
#define all(x)                (x).begin(), (x).end()
#define tr(x, it)             for(auto (it) = (x).begin();it != (x).end();it++)
#define fo(i, k, n)           for(int i = (k);i < (n);i++)
#define Fo(i, k, n)           for(int i = (k);i >= (n);i--)
#define el                    "\n"
#define ff                    first
#define ss                    second
#define ll                    long long
#define pb                    push_back
#define mp                    make_pair
#define pii                   pair<int, int>
#define vi                    vector<int>
#define mii                   map<int, int>
//#define pqb                   priority_queue<int>
//#define pqs                   priority_queue<int, vi, greater<int>>
//#define pc(x)                 putchar(x);
//#define setbits(x)            __builtin_popcountll(x)
//#define zrobits(x)            __builtin_ctzll(x)
#define mod                   1000000007
#define inf                   1e18
//#define ps(x, y)              fixed<<setprecision(y)<<x
//#define mk(arr, n, type)      type *arr = new type[n];
//#define w(x)                  int x; cin>>x; while(x--)
#define deb(x)                cout<<#x<< " = "<< x<<"\n";
int a[200], b[200];
int c[20], d[20];
ll ans = 0;
int n, m, k;

void dp(int i, int da[]){
	// deb(i)
	if(i == k){
		// fo(j, 1, n+1) cout<<da[j]<<" ";
		// cout<<el;
		// fo(j, 1, n+1) cout<<db[j]<<" ";
		// cout<<el;
		ll cnt = 0;
		fo(j, 0, m){
			if(da[a[j]] > 0 && da[b[j]] > 0) cnt++;
		}
		ans = max(ans, cnt);
		return;
	}
	da[c[i]]++;
	dp(i+1, da);
	da[c[i]]--;
	da[d[i]]++;
	dp(i+1, da);
	da[d[i]]--;
}

void solve(){
	cin>>n>>m;
	fo(i, 0, m){
		cin>>a[i]>>b[i];
	}
	cin>>k;
	fo(i, 0, k){
		cin>>c[i]>>d[i];
	}
	int da[200], db[200];
	memset(da, 0, sizeof(da));
	memset(db, 0, sizeof(db));
	dp(0, da);
	cout<<ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
	// cin>>t;	
	while(t--){
		solve();
		cout<<el;
	}
	return 0;
}