#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

void bottomleft(vector<vector<int> > &fp){
    int h = fp.size();
    int w = fp[0].size();
    int b=inf, l=inf;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(fp[i][j] > 0){
                b = min(b, i);
                l = min(l, j);
            }
        }
    }
    for(int i=0; i<h-b; i++){
        for(int j=0; j<w-l; j++){
            fp[i][j] = fp[i+b][j+l];
            fp[i+b][j+l] = 0;
        }
    }
}

void foldLtoR(vector<vector<int> > &fp, int c){
    int h = fp.size();
    for(int i=0; i<h; i++){
        for(int j=0; j<c; j++){
            fp[i][2*c-j-1] += fp[i][j];
            fp[i][j] = 0;
        }
    }
    bottomleft(fp);
}

void foldBtoU(vector<vector<int> > &fp, int c){
    int w = fp[0].size();
    for(int i=0; i<c; i++){
        for(int j=0; j<w; j++){
            fp[2*c-i-1][j] += fp[i][j];
            fp[i][j] = 0;
        }
    }
    bottomleft(fp);
}

int main(){
    while(1){
        int w,h,t,p;
        cin >> w >> h >> t >> p;
        if(w == 0) break;

        vector<vector<int> > fp(2*h, vector<int>(2*w, 0));
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                fp[i][j] = 1;
            }
        }
        for(int i=0; i<t; i++){
            int d,c;
            cin >> d >> c;
            if(d == 1) foldLtoR(fp, c);
            else foldBtoU(fp, c);
        }
        for(int i=0; i<p; i++){
            int x,y;
            cin >> x >> y;
            cout << fp[y][x] << endl;
        }
    }
    return 0;
}

