#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
#define int long long 
#define ll long long
#define all(a) a.begin(),a.end()    
#define rev(a) a.rbegin(),a.rend()    
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; //less_equal for multiset
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
//const double pi=acosl(-1);


void solve()
{
    int n;
    cin>>n;
    vector<pair<int,int>> a(n);
    fi(0,n) cin>>a[i].first>>a[i].second;
    int m;
    cin>>m;
    vector<pair<int,int>> op(m);
    fi(0,m)
    {
        cin>>op[i].first;
        if(op[i].first>2) cin>>op[i].second;
    }
    int Q;
    cin>>Q;
    vector<ar<int,3>> q(Q);
    fi(0,Q)
    {
        cin>>q[i][0]>>q[i][1];
        --q[i][0],--q[i][1];
        q[i][2]=i;
    }
    sort(all(q));
    vector<pair<int,int>> ans(Q);
    int j=0;
    while(j<Q&&q[j][0]==-1)
    {
        ans[q[j][2]]=a[q[j][1]];
        j++;
    }
    int rot=0;
    int flipx=0,flipy=0;
    int sx=1,sy=1;
    fi(0,m)
    {
        if(op[i].first>2)
        {
            if(op[i].first==3)
            {
                sx=-sx;
                flipx=2*op[i].second-flipx;
            }
            else
            {
                sy=-sy;
                flipy=2*op[i].second-flipy;
            }
        }
        else
        {
            if(op[i].first==1)
            {
                // rot++;
                swap(flipx,flipy);
                swap(sx,sy);
                rot=!rot;
                sy=-sy;
                flipy=-flipy;
            }
            else
            {
                // rot--;
                swap(flipx,flipy);
                swap(sx,sy);
                rot=!rot;
                sx=-sx;
                flipx=-flipx;
                // if(rot<0) rot+=4;
            }
        }
        while(j<Q&&q[j][0]==i)
        {
            int x=a[q[j][1]].first;
            int y=a[q[j][1]].second;
            //apply
            if(rot==1)
            {
                swap(x,y);
            }
            ans[q[j][2]]={x*sx+flipx,y*sy+flipy};   
            j++;
        }
    }
    for(auto temp:ans)
    {
        cout<<temp.first<<' '<<temp.second<<'\n';
    }
    

    
    
}

signed main()
{
    FAST;
    int tt=1;
    //cin>>tt;    
    while(tt--)
    {
        solve();
    }    
}

///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     FAST        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     ll 	        long long
#define 	pb 	        push_back
#define     pp          pop_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%lld",&i)
#define     scann(i,j)  scanf("%lld%lld",&i,&j)
#define     print(i)    printf("%lld\n",i)
#define     printt(i,j) printf("%lld %lld\n",i,j)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define     loopp(i,n) 	for(int i = 0 ; i <n-1 ; i++)
#define     rep(i,n)    for(int i=n-1;i>=0;i--)
#define     rev(v)      reverse(v.begin(),v.end())
#define     reset(a,b)  memset(a,b,sizeof(a))
#define 	vect 	    vector<ll>
#define 	vec_it 	    vector<ll>::reverse_iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define     sorted(v)   is_sorted(v.begin(),v.end())
#define 	mapp 	    map<ll,ll>
#define     rmap        map<ll,ll,greater<>>m
#define 	pairr 	    pair<ll,ll>
#define 	sett	    set<ll>
#define     rset        set<ll,greater<>>s
#define 	set_it 	    set<ll>::reverse_iterator si
#define     map_it      map<ll,ll> :: reverse_iterator mi
#define     digit(n)    floor(log10(n)+1)
#define 	yes 	    cout<<"YES"<<endl
#define 	no 	        cout<<"NO"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          INT_MAX
#define     lmx         LLONG_MAX
#define     mn          INT_MIN
#define     lmn         LLONG_MIN
#define     inf         0x3f3f3f3f
#define     inff        10e18
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
ll modulo (ll a, ll b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
   // freopen ("(input).txt" , "r",  stdin) ;
    string st,stt;
    ll low=0,high=0;
    ll l,r; char ch;
    ll n,k,t,x,y,z,d=0,cnt=0,temp=0,sum=0,f=0,flag=0;
    cin>>n>>k>>x>>y ; vect v ,a ; sett s ; mapp m,mm ; pairr p ;
    if(n==k)
        cout<<x<<endl;
    else if(n>k)
    {
        sum+=x;d=n;
        d--;
        if(2*x<=y)
            sum+=(d-k)*2*x;
        else
            sum+=(d-k)*y;
        cout<<sum<<endl;
    }
    else
    {
        sum+=x;
        if(2*x<=y)
            sum+=(k-n)*2*x;
        else
            sum+=(k-n)*y;
        cout<<sum<<endl;
    }



}

main()
{
    int t;
  //  cin>>t;
 //   while(t--)
        solve();
}



