#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

int Mod(int a) {
	if(a < 0)
		return (a+mod)%mod;
	else return a % mod;
}
int Mul(int a, int b) {
	return Mod(Mod(a) * Mod(b));
}
int Add(int a, int b) {
	return Mod(Mod(a) + Mod(b));
}
//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}


signed main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        int n;
        cin>>n;
        priority_queue<int>pq;
        unordered_map<int,int>vis;
        int mn = inf;
        for(int i = 0; i < n; i++) {
			int x;
			cin>>x;
			mn = min(mn,x);
			
			if(!vis[x]) {
				vis[x] = 1;
				pq.push(x);
			}
		}
		while(pq.size() > 1) {
			int mx = pq.top();
			pq.pop();
			int nw = mx%mn;
			if(!nw) cont;
			if(!vis[nw]) {
				vis[nw] = 1;
				if(nw < mn) mn = nw;
				pq.push(nw);
			}
		}
		cout<<mn<<endl;
		
		
        //for(int i = 0; i < n; i++) {
			//int x;
			//cin>>x;
			//if(!vis[x]) {
				//ip.pb(x);
				//vis[x] = 1;
			//}
		//}
		//sort(ip.begin(),ip.end());
		//if(ip.size() > 1) {
			//ans = ip[0];
			//for(int i = 1; i < ip.size(); i++) {
				//ans = min(ans,ip[i]-ip[i-1]
        
        
    }



return 0;
}

/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 61;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[201][12];

void cmemoInit(){
    rep(i, 201){
        rep(j, 12){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<pair<ll,ll>> ps;
    rep(i, n){
        ll x, y;
        cin >> x >> y;
        ps.push_back({x, y});
    }
    ll m;
    cin >> m;
    vector<pair<ll,ll>> ops;
    rep(i, m){
        ll t;
        cin >> t;
        if(t == 1 || t == 2){
            ops.push_back({t, -1});
        } else {
            ll p;
            cin >> p;
            ops.push_back({t, p});
        }
    }
    ll q;
    cin >> q;
    vector<pair<ll,ll>> qs;
    rep(i, q){
        ll a, b;
        cin >> a >> b;
        b--;
        qs.push_back({a, b});
    }

    ll x = 1, y = 1;
    pair<ll,ll> o = {0, 0};
    ll swp = 0;
    struct S{
        ll x;
        ll y;
        pair<ll,ll> o;
        ll swp;
    };
    vector<S> vec;
    vec.push_back({1, 1, {0, 0}, 0});
    rep(i, m){
        pair<ll,ll> op = ops[i];
        if(op.first == 1){
            x *= -1;
            swap(x, y);
            o.first *= -1;
            swap(o.first, o.second);
            swp--;
            swp %= 2;
            while(swp < 0) swp += 2;
        } else if(op.first == 2){
            y *= -1;
            swap(x, y);
            o.second *= -1;
            swap(o.first, o.second);
            swp++;
            swp %= 2;
            while(swp < 0) swp += 2;
        } else if(op.first == 3){
            //if(swp == 0){
                o.first += 2 * (op.second - o.first);
            //} else {
                //o.second += 2 * (op.second - o.second);
            //}
            x *= -1;
        } else {
            //if(swp == 0){
                o.second += 2 * (op.second - o.second);
            //} else {
                //o.first += 2 * (op.second - o.first);
            //}
            y *= -1;
        }
        vec.push_back({x, y, o, swp});
    }
    rep(i, q){
        S s = vec[qs[i].first];
        if(s.swp == 0){
            cout << ps[qs[i].second].first * s.x + s.o.first << " " << ps[qs[i].second].second * s.y + s.o.second << endl;
        } else {
            cout << ps[qs[i].second].second * s.x + s.o.first << " " << ps[qs[i].second].first * s.y + s.o.second << endl;
        }
    }

    
}