#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>


using namespace std;


#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)

int main() {
  int n, m, t, p;
  int a[700][700];
  while(cin >> n >> m >> t >> p, n){
    int zerox = 0, zeroy = 0;
    fill(a[0], a[699], 0);
    REP(i,n)REP(j,m) a[i][j] = 1;
    REP(i,t){
      int d, c;
      cin >> d >> c;
      if(d == 1){ // left
        zerox += c;
        for(int t = 0; t < c; t++){
          for(int y = zeroy; y < m + zeroy; y++){
            a[zerox + t][y] += a[zerox - 1 - t][y];
          }
        }
      }else{ // below
        zeroy += c;
        for(int t = 0; t < c; t++){
          for(int x = zerox; x < n + zerox; x++){
            a[x][zeroy + t] += a[x][zeroy - 1 - t];
          }
        }
      }
    }
    // Output    
    REP(i,p){
      int x, y;
      cin >> x >> y;
      cout << a[zerox + x][zeroy + y] << endl;
    }
  }
  return 0;
}

