#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int d[20], c[20], x[20], y[20];
int n, m, t, p;

void solve(vector<vector<int>> mass, int h, int w, int num){
  if(num == t){
    //こたえ合わせ

    REP(i,p){
      cout << mass[y[i]][x[i]] << endl;
    }
    return;
  }

  vector<vector<int>> new_mass;
  if(d[num] == 1){
    //超えないとき
    if(w / 2 >= c[num]){
      int new_h = h, new_w = w - c[num];

      new_mass = vector<vector<int>>(new_h, vector<int>(new_w, 0));
      //折り返し部分
      REP(i,new_h){
        REP(j,c[num]){
          new_mass[i][j] += mass[i][c[num]-j-1];
        }
      }
      //そのままの部分
      REP(i,new_h){
        REP(j,new_w){
          new_mass[i][j] += mass[i][c[num]+j];
        }
      }
    
      solve(new_mass, new_h, new_w, num+1);
    }else{
      int new_h = h, new_w = c[num];

      new_mass = vector<vector<int>>(new_h, vector<int>(new_w, 0));
      //そのままの部分
      REP(i,h){
        REP(j,w - c[num]){
          new_mass[i][j] += mass[i][c[num]+j];
        }
      }
      //折り返し部分
      REP(i,h){
        REP(j,new_w){
          new_mass[i][j] += mass[i][c[num]-j-1];
        }
      }

      solve(new_mass, new_h, new_w, num+1);
    }
  }else{
    //超えない時
    if(h / 2 >= c[num]){
      int new_h = h - c[num], new_w = w;

      new_mass = vector<vector<int>>(new_h, vector<int>(new_w, 0));
      //そのままの部分
      REP(i,new_h){
        REP(j,new_w){
          new_mass[i][j] += mass[c[num]+i][j];
        }
      }
      //折り返し
      REP(i,c[num]){
        REP(j,new_w){
          new_mass[i][j] += mass[c[num]-i-1][j];
        }
      }

      solve(new_mass, new_h, new_w, num+1);
    //越える時
    }else{
      int new_h = c[num], new_w = w;

      new_mass = vector<vector<int>>(new_h, vector<int>(new_w, 0));

      //そのまま
      REP(i,h - c[num]){
        REP(j,w){
          new_mass[i][j] += mass[c[num] + i][j];
        }
      }
      //折り返し
      REP(i,new_h){
        REP(j,new_w){
          new_mass[i][j] += mass[c[num]-i-1][j];
        }
      }

      solve(new_mass, new_h, new_w, num+1);
    }
  }
}

int main(){

  while(true){
    cin >> n >> m >> t >> p;
    if(n == 0 && m == 0 && t == 0 && p == 0) break;
    vector<vector<int>> mass;
    mass = vector<vector<int>>(m, vector<int>(n, 0));
    REP(i,m){
      REP(j,n){
        mass[i][j] = 1;
      }
    }
    REP(i,t){
      cin >> d[i] >> c[i];
    }
    REP(i,p){
      cin >> x[i] >> y[i];
    }

    solve(mass, m, n, 0);
  }
  return 0;
}



Measured memory_bytes: 3260