#include <bits/stdc++.h>
using namespace std;

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,t,p;


    while (true) {
      cin >> n >> m >> t >> p;
      if(n==0 && m==0) break;
      //グラフの領域を確保する
      VVI g(3*m,VI(3*n,0));
      int d[t],c[t];
      int x[p],y[p];
      rep(i,m) rep(j,n) g[i][j] = 1;

      rep(i,t) cin >> d[i] >> c[i];
      rep(i,p) cin >> x[i] >> y[i];

      // cout << "newg --------------------" << endl;
      // rep(y,m*3){
      //   rep(z,n*3) cerr<<g[y][z]<<" ";
      //   cerr<<endl;
      // }
      // cout << "--------------------" << endl;
      rep(i,t){ //命令のループ
        if (d[i]==1){// 左端から ci だけ右側を通る垂直の折り線の左側を右側に折り重ねる．
          VVI newg(3*m,VI(3*n,0));
          rep(j,m){
            rep(k,c[i]){
              //if(j == 0) printf("(%d,%d) = (%d,%d) + (%d,%d)\n",j,k,j,k,j,2*c[i]-1-k) ;
              newg[j][c[i]-1-k] = g[j][k] + g[j][2*c[i]-1-k];
            }
            FOR(k,c[i],n*2){
              newg[j][k] = g[j][k + c[i]];
            }
          }
          // copy newg -> g
          rep(height,3*m){
            rep(width,3*n){
              g[height][width] = newg[height][width];
            }
          }
          // cout << "1 --------------------" << endl;
          // rep(y,m*3){
          //   rep(z,n*3) cerr<<g[y][z]<<" ";
          //   cerr<<endl;
          // }
          // cout << "--------------------" << endl;
        }
        else{
          VVI newg(3*m,VI(3*n,0));
          rep(k,n){
            rep(j,c[i]){
              newg[c[i]-1-j][k] = g[j][k] + g[2*c[i]-1-j][k];
            }
            FOR(j,c[i],2*m){
              newg[j][k] = g[j+c[i]][k];
            }
          }

          int om = -1;
          int on = -1;
          bool flag = true;
          rep(height,3*m){
            rep(width,3*n){
              if(newg[height][width] != 0) {
                g[height][width] = newg[height][width];
                om = height;
                on = width;
                flag = false;
              }
              if(flag == false) break;
            }
            if(flag == false) break;
          }
          // copy newg -> g
          FOR(height,om,3*m-om){
            FOR(width,on,3*n-on){
              g[height][width] = newg[height][width];
            }
          }

          // cout << "2 --------------------" << endl;
          // rep(y,m*3){
          //   rep(z,n*3) cerr<<newg[y][z]<<" ";
          //   cerr<<endl;
          // }
          // cout << "--------------------" << endl;
        }
      }

      rep(i,p){
        cout<<g[y[i]][x[i]]<<endl;
      }

    }
    return 0;
}



Measured memory_bytes: 3284