//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); ++i)
#define all(x) (x).begin(), (x).end()
const int INF = 1e9;
const ll llINF = 1e18;
/*#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
*/

int main() {
    int N;
    cin >> N;
    vector<ll> X(N), Y(N);
    rep(i,0,N) cin >> X[i] >> Y[i];
    int M;
    cin >> M;
    vector<pair<int,ll>> op(M+1);
    rep(i,1,M+1) {
        cin >> op[i].first;
        if (op[i].first > 2) cin >> op[i].second;
    }
    int Q;
    cin >> Q;
    vector<pair<pair<int,int>,int>> q(Q);
    rep(i,0,Q) {
        int a, b;
        cin >> a >> b;
        q[i] = {{a, b-1}, i};
    }
    sort(all(q));

    vector<pair<ll,ll>> ans(Q);
    int cur = 0;
    while (cur < Q && q[cur].first.first == 0) {
        ans[q[cur].second] = {X[q[cur].first.second],Y[q[cur].first.second]};
        ++cur;
    }
    vector<ll> x = {1,0,0};
    vector<ll> y = {0,1,0};
    rep(i,1,M+1) {
        vector<ll> tmp_x, tmp_y;
        switch (op[i].first)
        {
        case 1:
            tmp_x = y;
            y = {-x[0], -x[1], -x[2]};
            x = tmp_x;
            break;
        
        case 2:
            tmp_y = x;
            x = {-y[0], -y[1], -y[2]};
            y = tmp_y;
            break;

        case 3:
            x[0] *= -1;
            x[1] *= -1;
            x[2] *= -1; x[2] += 2*op[i].second;
            break;

        case 4:
            y[0] *= -1;
            y[1] *= -1;
            y[2] *= -1; y[2] += 2*op[i].second;
            break;
        }

        while (cur < Q && q[cur].first.first == i) {
            ans[q[cur].second].first = x[0]*X[q[cur].first.second] + x[1]*Y[q[cur].first.second] + x[2];
            ans[q[cur].second].second = y[0]*X[q[cur].first.second] + y[1]*Y[q[cur].first.second] + y[2];
            ++cur;
        }
    }
    rep(i,0,Q) cout << ans[i].first << " " << ans[i].second << endl;
}
#include <bits/stdc++.h>
using namespace std;
#define FI ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pL pair<ll, ll>

const int MX=300000;
const ll mod=998244353;

int x[MX], y[MX];
vector<pair<ll, pair<int, int> > >dist;
vector<pL>dx, dy;

void cal(int i, int j)
{
    ll d=dx[j].ff-dx[i].ff;
    int jx=dx[j].ss, ix=dx[i].ss;
    if(jx<ix) swap(jx, ix);

    dist.push_back({d, {ix, jx}});
}

void cal2(int i, int j)
{
    ll d=dy[j].ff-dy[i].ff;
    int jx=dy[j].ss, ix=dy[i].ss;
    if(jx<ix) swap(jx, ix);

    dist.push_back({d, {ix, jx}});
}

ll ans()
{
    int m=5;
    while(m)
    {
        if(dist[m].ss==dist[m-1].ss) m--;
        else return dist[m-1].ff;
    }
}

int main()
{
    FI;

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

    for(int i=1; i<=n; i++) dx.push_back({x[i], i}), dy.push_back({y[i], i});

    sort(dx.begin(), dx.end());
    sort(dy.begin(), dy.end());

    cal(0, n-1);
    cal(0, n-2);
    cal(1, n-1);

    cal2(0, n-1);
    cal2(0, n-2);
    cal2(1, n-1);

    sort(dist.begin(), dist.end());

    cout<<ans()<<endl;

    return 0;
}
