#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
long long A[200001][2];
long long B[200001][2];
long long C[200001][2];
int main() {
	int N;
	cin >> N;
	vector<long long>X(N);
	vector<long long>Y(N);
	rep(i, N) {
		cin >> X[i] >> Y[i];
	}
	int M;
	cin >> M;
	A[0][0] = 1;
	B[0][1] = 1;
	rep(i, M) {
		int op;
		cin >> op;
		if (op <= 2) {
			if (1 == op) {
				//(a,b)->(b,-a)
				A[i + 1][0] = A[i][1];
				B[i + 1][0] = B[i][1];
				C[i + 1][0] = C[i][1];
				A[i + 1][1] = -A[i][0];
				B[i + 1][1] = -B[i][0];
				C[i + 1][1] = -C[i][0];
			}
			else {
				//(a,b)->(-b,a)
				A[i + 1][0] = -A[i][1];
				B[i + 1][0] = -B[i][1];
				C[i + 1][0] = -C[i][1];
				A[i + 1][1] = A[i][0];
				B[i + 1][1] = B[i][0];
				C[i + 1][1] = C[i][0];
			}
		}
		else {
			long long p;
			cin >> p;
			if (3 == op) {
				//(a,b)->(2p-a,b)
				A[i + 1][0] = -A[i][0];
				B[i + 1][0] = -B[i][0];
				C[i + 1][0] = 2 * p - C[i][0];
				A[i + 1][1] = A[i][1];
				B[i + 1][1] = B[i][1];
				C[i + 1][1] = C[i][1];
			}
			else {
				//(a,b)->(a,2p-b)
				A[i + 1][0] = A[i][0];
				B[i + 1][0] = B[i][0];
				C[i + 1][0] = C[i][0];
				A[i + 1][1] = -A[i][1];
				B[i + 1][1] = -B[i][1];
				C[i + 1][1] = 2 * p - C[i][1];
			}
		}
	}
	int Q;
	cin >> Q;
	rep(i, Q) {
		int a, b;
		cin >> a >> b;
		b--;
		long long x = A[a][0] * X[b] + B[a][0] * Y[b] + C[a][0];
		long long y = A[a][1] * X[b] + B[a][1] * Y[b] + C[a][1];
		cout << x << " " << y << endl;
	}
	return 0;
}
//#include <atcoder/all>
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
//using namespace atcoder;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<pair<ll,double>>>;

vector<pair<ll,ll>> Z;
double dist(ll A,ll B){
    ll dx=Z[A].first-Z[B].first;
    ll dy=Z[A].second-Z[B].second;
    return sqrt(dx*dx+dy*dy);
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}
ll mod=1e9+7;




int main() {
   
   ll N;
   cin>>N;
   vector<pair<ll,string>> P(N);
    rep(i,N){
        ll H;string S;
        cin>>S>>H;
        P[i]=make_pair(H,S);
    }
    sort(all(P));
    reverse(all(P));
    cout<<P[1].second<<endl;

}