#include <bits/stdc++.h>

#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vpii = vector<pair<ll,ll>>;

vvi matrix_product(vvi a,vvi b) {
    vvi matrix(3,vi(3,0));
    REP(i,3)REP(j,3)REP(k,3) {
        matrix[i][j] += a[i][k] * b[k][j];
    }
    return matrix;
}

void solve() {
  
     const auto op1 = []()-> vvi {
        vvi matrix(3,vi(3,0));
        matrix[0][1] = 1;
        matrix[1][0] = -1;
        matrix[2][2] = 1;
        return matrix;
    }();
  
    const auto op2 = []()-> vvi {
        vvi matrix(3,vi(3,0));
        matrix[0][1] = -1;
        matrix[1][0] = 1;
        matrix[2][2] = 1;
        return matrix;
    }();

    const auto gen_op4 = [](int p)-> vvi {
        vvi matrix(3,vi(3,0));
        matrix[0][0] = 1;
        matrix[1][1] = -1;
        matrix[1][2] = 2 * p;
        matrix[2][2] = 1;
        return matrix;
    };

    const auto gen_op3 = [](int p)-> vvi {
        vvi matrix(3,vi(3,0));
        matrix[0][0] = -1;
        matrix[0][2] = 2 * p;
        matrix[1][1] = 1;
        matrix[2][2] = 1;
        return matrix;
    };



    int N; cin >> N;
    vpii pieces(N);
    REP(i,N) {
        int X,Y; cin >> X >> Y;
        pieces[i] = make_pair(X,Y);
    }

    vvi matrix(3,vi(3,0));
    
    // 正則行列にする。
    REP(i,3) matrix[i][i] = 1;

    int M; cin >> M;
    
    // x回目の累積積
    vvvi states(M+1,vvi(3,vi(3,0)));
    states[0] = matrix;

    FOR(i,1,M+1) {
        int op; cin >> op;
        if (op == 1) states[i] = matrix_product(op1,states[i-1]);
        else if (op == 2) states[i] = matrix_product(op2,states[i-1]);
        else if (op == 3) {
            int p; cin >> p;
            states[i] = matrix_product(gen_op3(p),states[i-1]);
        }
        else if (op == 4) {
            int p; cin >> p;
            states[i] = matrix_product(gen_op4(p),states[i-1]);
        }
        else assert(false);
    }

    int Q; cin >> Q;
    REP(_,Q) {
        int A,B; cin >> A >> B; --B;
        
        vvi piece_matrix(3,vi(3,0));
        piece_matrix[0][0] = pieces[B].first;
        piece_matrix[1][0] = pieces[B].second;
        piece_matrix[2][0] = 1;

        auto ans = matrix_product(states[A],piece_matrix);
        cout << ans[0][0] << " " << ans[1][0] << endl;
    }
}

int main() {
    solve();
    return 0;
}



#include <iostream>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <string>

using namespace std;

typedef long long int ll;


int gcd(int a, int b)
{

    while (a>0 && b>0)
    {
        if (a>b)
        {
            int c=b;
            b=a%b;
            a=c;
        }
        else
        {
            int c=a;
            a=b%c;
            b=c;
        }

    }

    return max(a,b);
}

int n,m;

int counter;

vector<vector<int>> r;

vector<int> used;


void dfs(int v)
{
    used[v]=1;
    counter++;

    for (auto x : r[v])
        if (used[x]==0)
            dfs(x);
}

void inputdirgr()
{
    cin>>n>>m;

    r.resize(n);

    for (int i=0; i<m; i++)
    {
        int a,b;
        cin>>a>>b;

        a--;
        b--;

        r[a].push_back(b);
    }
}

int t[100];

int a[100][200001];

int main()
{
    int x,y;

    int n;

    cin>>n;

    int T=0;
    for (int i=0; i<n; i++)
    {
        cin>>t[i];
        T+=t[i];
    }


    for (int i=0; i<n; i++)
        for (int q=0; q<200001; q++)
            a[i][q]=T+1;

    a[0][100000+t[0]]=t[0];
    a[0][100000-t[0]]=t[0];

    for (int i=1; i<n; i++)
        for (int q=-T; q<=T; q++)
            if (a[i-1][100000+q]!=T+1)
            {
                if (q<0)
                {
                int ttt=a[i-1][100000+q];
                int t1=max(q+t[i]+ttt,ttt);
                int q1=q+t[i];

                int t2=t[i]+ttt;
                int q2=q-t[i];

                a[i][100000+q1]=min(a[i][100000+q1],t1);
                a[i][100000+q2]=min(a[i][100000+q2],t2);
                }
                else
                {
                int ttt=a[i-1][100000+q];
                int t1=t[i]+ttt;
                int q1=q+t[i];

                int t2=max(-q+t[i]+ttt,ttt);
                int q2=q-t[i];

                a[i][100000+q1]=min(a[i][100000+q1],t1);
                a[i][100000+q2]=min(a[i][100000+q2],t2);
                }
            }

     int mint=T;

     for (int i=0; i<200001; i++)
         if (a[n-1][i]<mint)
             mint=a[n-1][i];

     cout<<mint;

    /*counter=0;

    for (int i=0; i<n; i++)
    {
        used.assign(n,0);

        dfs(i);
    }

    cout<<counter;*/

	return 0;
}

