//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

#include <utility>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;

template <typename T>
void do_uniq(vector<T> &vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#ifndef ONLINE_JUDGE
clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}
#endif


#ifdef _getchar_nolock
#else
#    define _getchar_nolock getchar_unlocked
#endif

#define integer int

const integer mod = 998244353;

integer ml(integer a, integer b) {
    return (a * 1ll * b) % mod;
}

integer add(integer a, integer b) {
    integer rt = a + b;
    if (rt < mod) return rt;
    return rt - mod;
}

integer sub(integer a, integer b) {
    return add(a, mod - b);
}

integer sq(integer a) {
    return ml(a, a);
}

integer b_p(integer b, ll p) {
    if (p == 0) return 1;
    if (p & 1) return ml(b, b_p(b, p - 1));
    return sq(b_p(b, p >> 1));
}

const ll inf = 1e18 + 231;

#define solvsh
//#define multi

#ifdef solvsh

void precalc() {}
const int INF = 2e9;

const int MAXN = 1e4 + 32;
const int MAXM = 2e5 + 32;

pair<pair<ll, pair<ll, ll>>, pair<ll, pair<ll, ll>>> eqs[MAXM];

void solve() {

    int n;
    cin >> n;
    vector<pair<int, int>> v;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        v.push_back({x, y});
    }

    eqs[0] = {{1, {0, 0}},
              {0, {1, 0}}};

    int m;
    cin >> m;

    for (int i = 1; i <= m; ++i) {
        int p;
        cin >> p;
        if (p == 1) {
            eqs[i] = {
                    eqs[i - 1].second,
                    {-eqs[i - 1].first.first, {-eqs[i - 1].first.second.first, -eqs[i - 1].first.second.second}}
            };
        } else if (p == 2) {
            eqs[i] = {
                    {-eqs[i - 1].second.first, {-eqs[i - 1].second.second.first, -eqs[i - 1].second.second.second}},
                    eqs[i - 1].first
            };
        } else if (p == 3) {
            int x;
            cin >> x;
            eqs[i] = {
                    {-eqs[i - 1].first.first, {-eqs[i - 1].first.second.first, 2 * x - eqs[i - 1].first.second.second}},
                    eqs[i - 1].second
            };
        } else {
            int y;
            cin >> y;
            eqs[i] = {
                    eqs[i - 1].first,
                    {-eqs[i - 1].second.first,
                     {-eqs[i - 1].second.second.first, 2 * y - eqs[i - 1].second.second.second}}
            };
        }
    }

    int q;
    cin >> q;

    while (q--) {
        int a, b;
        cin >> a >> b;
        --b;
        auto eq = eqs[a];
        ll x = v[b].first;
        ll y = v[b].second;


        cout << eq.first.first * x + eq.first.second.first * y + eq.first.second.second << " "
             << eq.second.first * x + eq.second.second.first * y + eq.second.second.second << "\n";
    }
}

#else

void precalc() {}

void solve() {}

#endif

void multisolve() {
    precalc();
    int t;

    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

void singlesolve (){
    precalc();
    solve();
}

#ifndef ONLINE_JUDGE

void gen() {
}


#endif

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    //            gen();
    multisolve();
#else
    singlesolve();
//    gen();
#endif

}
/**
 * Author: Daniel
 * Created Time: 2021-04-03 10:23:06
**/

#include <bits/stdc++.h>

using namespace std;

#define F first 
#define S second
#define ER erase
#define IS insert
#define PI acos(-1)
#define PB pop_back
#define MP make_pair
#define MT make_tuple
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define lowbit(x) (x & -x)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define SOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10)

typedef long long LL;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<bool> VB;
typedef pair<LL, LL> PLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef unsigned long long ULL;
typedef pair<double, double> PDD;
typedef vector<pair<LL, LL> > VPLL;
typedef vector<pair<int, int> > VPII;

template <typename A> using VE = vector<A>;
template <typename A> using USET = unordered_set<A>;
template <typename A> using HEAP = priority_queue<A>;
template <typename A, typename B> using PA = pair<A, B>;
template <typename A, typename B> using UMAP = unordered_map<A, B>;
template <typename A> using RHEAP = priority_queue<A, vector<A>, greater<A> >;

template <typename A> A MAX(const A &a) { return a; }
template <typename A> A MIN(const A &a) { return a; }
template <typename A> A MAX(const A *a, const A *b) { return *max_element(a, b); }
template <typename A> A MIN(const A *a, const A *b) { return *min_element(a, b); }
template <typename A, typename... B> A MAX(const A &a, const B&... b) { return max(a, MAX(b...)); }
template <typename A, typename... B> A MIN(const A &a, const B&... b) { return min(a, MIN(b...)); }
template <typename A, typename B = typename std::iterator_traits<A>::value_type> B MAX(A a, A b) { return *max_element(a, b); }
template <typename A, typename B = typename std::iterator_traits<A>::value_type> B MIN(A a, A b) { return *min_element(a, b); }

mt19937 rng((unsigned int)chrono::steady_clock::now().time_since_epoch().count());

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

// check the limitation!!!
const int N = 100010, M = 1010;



// read the question carefully!!!
int main()
{
    SOS;

    int n;
    cin >> n;
    VPLL a(n);
    for (auto &[x, y] : a) cin >> x >> y;
    int m;
    cin >> m;
    bool flag = false;
    LL sx = 1, sy = 1;
    LL cx = 0, cy = 0;
    VE<tuple<bool, LL, LL, LL, LL>> op;
    op.EB(MT(flag, sx, cx, sy, cy));
    for (int i = 0; i < m; i ++ )
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            flag = !flag;
            sx = -sx;
            cx = -cx;
            swap(sx, sy);
            swap(cx, cy);
        }
        else if (t == 2)
        {
            flag = !flag;
            sy = -sy;
            cy = -cy;
            swap(sx, sy);
            swap(cx, cy);
        }
        else if (t == 3)
        {
            LL p;
            cin >> p;
            sx = -sx;
            cx = 2 * p - cx;
        }
        else if (t == 4)
        {
            LL p;
            cin >> p;
            sy = -sy;
            cy = 2 * p - cy;
        }
        else assert(false);
        op.EB(MT(flag, sx, cx, sy, cy));
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i ++ )
    {
        int c, b;
        cin >> c >> b;
        b -- ;
        LL x, y;
        auto [flag, sx, cx, sy, cy] = op[c];
        if (!flag) x = sx * a[b].F + cx, y = sy * a[b].S + cy;
        else x = sx * a[b].S + cx, y = sy * a[b].F + cy;
        cout << x << ' ' << y << '\n';
    }
    return 0;
}

// GOOD LUCK!!!
