#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll fp[3][250005];
struct node
{
    ll op, po;
}p[250005];


struct qu
{
    ll A, B, id;
}q[250005];

int cmp(qu z1, qu z2)
{
    return z1.A<z2.A;
}

struct nn
{
    ll rx, ry;
}res[250005];

int main()
{
    int n;
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld %lld", &fp[1][i], &fp[2][i]);
    }
    ll m;
    scanf("%lld", &m);
    for(int i=1; i<=m; i++)
    {
        scanf("%lld", &p[i].op);
        if(p[i].op>2)
        {
            scanf("%lld", &p[i].po);
        }
    }
    ll Q;
    scanf("%lld", &Q);
    for(int i=1; i<=Q; i++)
    {
        scanf("%lld %lld", &q[i].A, &q[i].B);
        q[i].id=i;
    }
    sort(q+1,q+1+Q, cmp);
    ll ra[3];
    ra[1]=1LL;ra[2]=2LL;
    ll f1[3], f2[3], cnt=1;
    f1[1]=f1[2]=0LL;
    f2[1]=f2[2]=1LL;
    for(int i=1; i<=Q; i++)
    {
        for(int j=cnt; j<=q[i].A; j++)
        {
            if(p[j].op==2)
            {
                swap(ra[1], ra[2]);
                swap(f1[1], f1[2]);
                swap(f2[1], f2[2]);

                f1[1]*=-1;
                f2[1]*=-1;


            }
            else if(p[j].op==1)
            {
                swap(ra[1], ra[2]);
                swap(f1[1], f1[2]);
                swap(f2[1], f2[2]);
                f1[2]*=-1;
                f2[2]*=-1;


            }
            else if(p[j].op==4)
            {
                f1[2]=2*p[j].po-f1[2];
                f2[2]*=-1;
            }
            else
            {
                f1[1]=2*p[j].po-f1[1];
                f2[1]*=-1;

            }

        }

        //printf("%d %lld %lld %lld %lld\n",i, f1[1], f1[2], f2[1], f2[2]);
        res[q[i].id].rx=f1[1]+f2[1]*fp[ra[1]][q[i].B];
        res[q[i].id].ry=f1[2]+f2[2]*fp[ra[2]][q[i].B];
        cnt=q[i].A+1;
    }
    for(int i=1; i<=Q; i++)
    {
        printf("%lld %lld\n", res[i].rx, res[i].ry);
    }

}

#include <bits/stdc++.h>
#define endl '\n'
#define fr first
#define sc second
#define all(v) v.begin(),v.end()
#define unq(v) sort( all(v) ); v.erase( unique( all(v) ), v.end() )
#define bout(x) cout << bitset<sizeof(x)*8>(x) << endl
#define mkp(a,b) make_pair(a,b)
#define gcd(a,b) __gcd(a,b)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using cpl = complex<ld>;
const ld pi = 3.14159265358979323846264338327950288;
const ld tau = 2 * pi;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, ddy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int nx[8] = {1, 2, 2, 1, -1, -2, -2, -1}, ny[8] = {-2, -1, 1, 2, 2, 1, -1, -2};

//#define DEBUG
typedef pair<int, bool> pib;

int arr[400020];
pii srt[400020];
bool add[400020];
stack<pib> st;
vector<int> v1, v2;

void Main(){
	int n; cin >> n;
	for (int i = 1; i <= 2*n; i++){
		cin >> arr[i];
		srt[i] = {i, arr[i]};
	}
	sort(srt+1, srt+2*n+1, [](pii a, pii b){
		return a.sc > b.sc;
	});
	for (int i = 1; i <= n; i++){
		add[ srt[i].fr ] = 1;
		//cout << srt[i].fr << ' ';
	}
	for (int i = 1; i <= 2*n; i++){
		if (st.empty()){ st.push({i, add[i]}); }
		else{
			if (st.top().sc != add[i]){
				v1.push_back(st.top().fr); v2.push_back(i);
				st.pop();
			}
			else{
				st.push({i, add[i]});
			}
		}
	}
	sort(all(v1)); sort(all(v2));
	int p1 = 0, p2 = 0;
	string s = "";
	for (int i = 1; i <= 2*n; i++){
		if (p1 == n){ s += ')'; p2 += 1; }
		else if (p2 == n){ s += '('; p1 += 1; }
		else if (v1[p1] == i){ s += '('; p1 += 1; }
		else{ s += ')'; p2 += 1; }
	}
	cout << s;
}

int main(){
#ifndef DEBUG
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#endif
	cout.setf(ios::fixed);
	cout.precision(0);
	Main();
}
