#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=(a),(i##i)=(b);i<=(i##i);++i)
#define Rep(i,n) for(int i=0,(i##i)=(n);i<(i##i);++i)
#define Fodn(i,a,b) for(int i=(a),(i##i)=(b);i>=(i##i);--i)
#define pln puts("")
#define il inline
#define ff first
#define ss second
using LL=long long;using u32=unsigned int;using u64=unsigned LL;using LD=long double;
template<typename T>using pii=pair<T,T>;
template<typename T>il bool read(T&x){
x=0;char c=getchar();int f=1;while(!isdigit(c)&&(c!='-')&&(c!=EOF))c=getchar();
if(c==EOF)return 0;if(c=='-')f=-1,c=getchar();
while(isdigit(c)){x=(x<<1)+(x<<3)+(c&15);c=getchar();}x*=f;return 1;}
template<typename T,typename...Args>
il bool read(T&x,Args&...args){bool res=1;res&=read(x);res&=read(args...);return res;}
const int M=1000000007,INF=0x3f3f3f3f;const LL INFLL=0x3f3f3f3f3f3f3f3fLL;
const int N=500010;const double EPS=1e-6;

LL n,m,q;
LL a[N],b[N];
bool f=0;
LL g[2]={1,1};
LL u,v;
struct HIS{
    bool f;
    LL g[2];
    LL u,v;
}hist[N];
il void sav(int x){
    hist[x].f=f;
    hist[x].g[0]=g[0];hist[x].g[1]=g[1];
    hist[x].u=u;hist[x].v=v;
}

inline void init(){
    read(n);For(i,1,n)read(a[i],b[i]);
    u=a[1],v=b[1];read(m);g[0]=1;g[1]=1;
    sav(0);
    For(i,1,m){
        int op;read(op);
        if(op==1){
            g[0^f]*=-1;f^=1;
            swap(u,v);v*=-1;
        }else if(op==2){
            g[1^f]*=-1;f^=1;
            swap(u,v);u*=-1;
        }else if(op==3){
            LL p;read(p);
            g[0^f]*=-1;
            u=2*p-u;
        }else{
            LL p;read(p);
            g[1^f]*=-1;
            v=2*p-v;
        }
        sav(i);
    }
}
inline void solve(){
    read(q);
    while(q--){
        LL ai,bi;read(ai,bi);
        LL hu=hist[ai].u,hv=hist[ai].v;
        if(hist[ai].f)swap(hu,hv);
        LL ansx=hu+hist[ai].g[0]*(a[bi]-a[1]),ansy=hv+hist[ai].g[1]*(b[bi]-b[1]);
        if(hist[ai].f)swap(ansx,ansy);
        printf("%lld %lld\n",ansx,ansy);
    }
}
signed main(){
    init();solve();
    return 0;
}
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;
void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);}
void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}
void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);}
void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);}
void ioinit() { cout << fixed << setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); }
// clang-format on

ll fibrest(ll x0, ll y0, ll n, bool isx) {
    ll iter = 0;
    vector<ll> fib = {x0, y0};
    ll x = x0;
    ll y = y0;
    ll op = 0;
    while (true) {
        if (isx) {
            x = x + y;
        } else {
            y = y + x;
        }
        if (x >= n) break;
        op++;
        isx = !isx;
    }
    return op;
}
void op(vector<ll> &ops, ll &x, ll &y, ll t) {
    if (t == 1) {
        x = x + 1;
    }
    if (t == 2) {
        y = y + 1;
    }
    if (t == 3) {
        x = x + y;
    }
    if (t == 4) {
        y = y + x;
    }
    ops.push_back(t);
}
void output(vector<ll> &ops) {
    ll k = ops.size();
    print(ops.size());
    for (auto ope : ops) {
        print(ope);
    }
}

bool solve(ll n) {
    ll x = 0;
    ll y = 0;
    vector<ll> ops;
    if (n < 10) {
        while (x < n) {
            op(ops, x, y, 1);
        }
        output(ops);
        return true;
    }

    op(ops, x, y, 1);
    bool isx = false;
    while (true) {
        if (x + y > n) {
            while (x < n) {
                op(ops, x, y, 1);
            }
            break;
        }
        ll curop = fibrest(x, y, n, isx);

        {
            ll k = 0;
            while (true) {
                ll r = fibrest(x + k + 1, y, n, isx);
                if (r != curop) break;
                //perr(curop, r);
                op(ops, x, y, 1);
                k = k + 1;
            }
        }
        if (isx) {
            op(ops, x, y, 3);
        } else {
            op(ops, x, y, 4);
        }
        isx = !isx;
        if (x >= n) break;
    }
    if (ops.size() > 130) {
        return false;
    }
    output(ops);
    return true;
}
int main() {
    ioinit();

    ll n;
    cin >> n;
    if (!solve(n)) {
        assert(false);
    }
    return 0;
    // for (ll i = 1000000000000000000; true; i--) {
    //     if (!solve(i)) {
    //         assert(false);
    //         return 0;
    //     }
    // }
}
