#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

void solve() {
    int n;
    cin>>n;

    vector<pii> vec(n);
    for(auto& it : vec) cin>>it.first>>it.second;

    int m;
    cin>>m;

    vector<vector<ll>> add(m+1, vector<ll>(6));
    ll flip[m+1] = {0};
    add[0][0] = 1;
    add[0][1] = 0;
    add[0][2] = 0;
    add[0][3] = 0;
    add[0][4] = 1;
    add[0][5] = 0;
    for(int j = 1; j <= m; ++j) {
        int type;
        cin>>type;
        ll prevc1 = add[j-1][0];
        ll prevd1 = add[j-1][1];
        ll prevz1 = add[j-1][2];
        ll prevc2 = add[j-1][3];
        ll prevd2 = add[j-1][4];
        ll prevz2 = add[j-1][5];

        ll nprevc1 = 0;
        ll nprevd1 = 0;
        ll nprevz1 = 0;
        ll nprevc2 = 0;
        ll nprevd2 = 0;
        ll nprevz2 = 0;
        if(type == 1) {
            nprevc1 = prevc2;
            nprevd1 = prevd2;
            nprevz1 = prevz2;
            nprevc2 = -prevc1;
            nprevd2 = -prevd1;
            nprevz2 = -prevz1;
        }
        else if(type == 2) {
            nprevc1 = -prevc2;
            nprevd1 = -prevd2;
            nprevz1 = -prevz2;
            nprevc2 = prevc1;
            nprevd2 = prevd1;
            nprevz2 = prevz1;
        }
        else if(type == 3) {
            ll p;
            cin>>p;
            nprevc1 = -prevc1;
            nprevd1 = -prevd1;
            nprevz1 = 2*p - prevz1;
            nprevc2 = prevc2;
            nprevd2 = prevd2;
            nprevz2 = prevz2;
        }
        else {
            ll p;
            cin>>p;
            nprevc1 = prevc1;
            nprevd1 = prevd1;
            nprevz1 = prevz1;
            nprevc2 = -prevc2;
            nprevd2 = -prevd2;
            nprevz2 = 2*p - prevz2;
        }

        add[j][0] = nprevc1;
        add[j][1] = nprevd1;
        add[j][2] = nprevz1;
        add[j][3] = nprevc2;
        add[j][4] = nprevd2;
        add[j][5] = nprevz2;
    }

    int q;
    cin>>q;
    while(q--) {
        int a, b;
        cin>>a>>b;
        ll ax = vec[b-1].first;
        ll ay = vec[b-1].second;
        cout<<ax*add[a][0]+ay*add[a][1]+add[a][2]<<" "<<ax*add[a][3]+ay*add[a][4]+add[a][5]<<endl;
    }
}

int32_t main()  {
    fastio 
    int t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
} 
#include <bits/stdc++.h>
using namespace std;

#define M1 1000000007
#define M3 1000000009
#define M2 998244353
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define csv(v) for(int i=0;i<v.size();i++)cout<<v[i]<<' '
#define yep cout<<"YES"<<'\n'
#define nope cout<<"NO"<<'\n'
#define CASE(te) ll te; cin>>te; while(te--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int main()
{
  FAST();
  int n;
  cin>>n;
  int mn=100000,mx=0;
    for(int i=0;i<n;i++)
  {
      int a;
      cin>>a;
      mx=max(a,mx);
  }
  for(int i=0;i<n;i++)
  {
      int a;
      cin>>a;
      mn=min(a,mn);
  }
  if(mn>=mx)
  cs(mn-mx+1);
  else
  cs(0);
}