#include <iostream>
using namespace std;
int f[16][16],p[16][2];
int h,w,a,b,a1,b1;

int  set1(int j,int k){
  int i0,i1;
  i0=j/w;
  i1=j%w;
  if(f[i0][i1]==1)
    return 0;
  switch(k){
    case 1:
      if(a1==0||i0+1==h||f[i0+1][i1]==1)
        return 0;
      f[i0][i1]=1;
      f[i0+1][i1]=1;
      a1--;
      break;
    case 2:
      if(a1==0||i1+1==w||f[i0][i1+1]==1)
        return 0;
      f[i0][i1]=1;
      f[i0][i1+1]=1;
      a1--;
      break;
    case 3:
      if(b1==0)
        return 0;
      f[i0][i1]=1;
      b1--;
  }
  return 1;
}

void set0(int j,int k){
  int i0,i1;
  i0=j/w;
  i1=j%w;
  switch(k){
    case 1:
      f[i0][i1]=0;
      f[i0+1][i1]=0;
      a1++;
      break;
    case 2:
      f[i0][i1]=0;
      f[i0][i1+1]=0;
      a1++;
      break;
    case 3:
      f[i0][i1]=0;
      b1++;
  }
}

int main(){
  int l,i,j,k,c=0;
  cin >> h >> w >> a >> b;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      f[i][j]=0;
    }
  }
  a1=a;
  b1=b;
  l=0;
  p[0][0]=0;
  while(l>=0){
    if(p[l][0]==4){
      l--;
      continue;
    }
    if(p[l][0]){
      k=p[l][1];
      set0(k,p[l][0]);
    } else {
      for(k=0;k<h*w;k++){
        if(f[k/w][k%w]==0)
          break;
      }
    }
    for(i=p[l][0]+1;i<=3;i++){
      if(set1(k,i)){
        break;
      }
    }
    p[l][0]=i;
    if(i<=3){
      p[l][1]=k;
      if(l==a+b-1){
        c++;
      } else {
		l++;
        p[l][0]=0;
      }
    }
  }
  cout << c << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define print(a) cout << a << endl
#define fix(n) fixed << setprecision(n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Yes "Yes"
#define YES "YES"
#define No "No"
#define NO "NO"


int main() {
  int N, M, Q;
  cin >> N;
  vec<ll> X(N), Y(N);
  rep(i,N)
    cin >> X[i] >> Y[i];
  cin >> M;
  vec<ll> ax(M+1), ay(M+1), bx(M+1), by(M+1), sw(M+1,0);
  ax[0] = 1; ay[0] = 1;
  bx[0] = 0; by[0] = 0;
  rep(i,M) {
    int op,p;
    cin >> op;
    if ((op==1 && sw[i]==1) || (op==2 && sw[i]==0)) {
      ax[i+1] = ax[i];
      ay[i+1] = ay[i]*(-1);
      bx[i+1] = bx[i];
      by[i+1] = by[i]*(-1);
      sw[i+1] = (sw[i]+1)%2;
    } else if ((op==1 && sw[i]==0) || (op==2 && sw[i]==1)) {
      ax[i+1] = ax[i]*(-1);
      ay[i+1] = ay[i];
      bx[i+1] = bx[i]*(-1);
      by[i+1] = by[i];
      sw[i+1] = (sw[i]+1)%2;
    } else {
      cin >> p;
      if ((op==3 && sw[i]==1) || (op==4 && sw[i]==0)) {
        ax[i+1] = ax[i];
        ay[i+1] = ay[i]*(-1);
        bx[i+1] = bx[i];
        by[i+1] = 2*p-by[i];
        sw[i+1] = sw[i];
      } else {
        ax[i+1] = ax[i]*(-1);
        ay[i+1] = ay[i];
        bx[i+1] = 2*p-bx[i];
        by[i+1] = by[i];
        sw[i+1] = sw[i];
      }
    }
  }
  cin >> Q;
  rep(_,Q) {
    int A,B;
    cin >> A >> B;
    B--;
    ll x = X[B], y = Y[B];
    x = ax[A]*x + bx[A];
    y = ay[A]*y + by[A];
    if (sw[A])
      swap(x,y);
    print(x << " " << y);
  }
  return 0;
}