#include <iostream>
#include <string>
#include <vector>
#include <algorithm>    // std::copy
using namespace std;

int main(void){
    // Your code here!
    while(true){
        int n,m,t,p;
        cin >> n >> m >> t >> p;
        
        if(n == 0 && m == 0 && t == 0 && p == 0){
            break;
        }
        vector <int> origami(n*m,1);
        for(int i=0;i<t;i++){
            int way;
            int c;
            cin >> way >> c;
            vector <int> origamiTemp;
            switch(way){
            case 1://横
                if(n / 2 >= c){
                    for(int j = 0;j<m;j++){
                        for(int k=0;k<n-c;k++){
                            int value = origami[k + c + j*n];
                            if(k < c){
                                value += origami[(c - k - 1) + j*n];
                            }
                            
                            origamiTemp.push_back(value);
                        }
                    }
                    n = n - c;
                }else{
                    //cout << "success" << c << endl;;
                    for(int j = 0;j<m;j++){
                        for(int k=0;k<c;k++){
                            int value;
                            if(k >= n - c){
                                //int pos = k - (n - c);
                                //int num = n - c - pos ;
                                value = origami[c - k - 1  + j*n];
                                //cout << num <<" ";
                                //cout << num + j* n <<" ";
                            }else{
                                value = origami[c + k + j*n] + origami[c - 1 - k + j*n];
                                //cout << "aaa" << " ";
                            }
                            //cout << value <<" " <<k <<endl;
                            origamiTemp.push_back(value);
                        }
                        //cout << endl;
                    }
                    //cout <<endl;
                    n = c;
                }
                break;
            case 2://縦
                if(m / 2 >= c){
                    for(int j = 0;j<m-c;j++){
                        for(int k=0;k<n;k++){
                            int value = origami[k + j*n];
                            if(j >= m - 2*c){
                                int temp = j - (m - 2*c);
                                value += origami[k + (m - temp - 1)*n];
                            }
                            
                            origamiTemp.push_back(value);
                        }
                    }
                    m = m - c;
                }else{
                    for(int j = 0;j<c;j++){
                        for(int k=0;k<n;k++){
                            int value;
                            if(j < 2 * c - m){
                                value = origami[k+(m - j - 1)*n];
                            }else{
                                int c2m = 2 * c - m;
                                int pos = j - c2m;
                                value = origami[k + (pos)*n] + origami[k + (m - j - 1)*n];
                            }
                            
                            origamiTemp.push_back(value);
                        }
                    }
                    m = c;
                }
                break;
            }
            origami = origamiTemp;
            /*for(int i=0;i<m;i++){
                for(int j=0;j<n;j++){
                    cout<<origami[j +i * n] <<" ";
                }
                cout << endl;
            }
            cout <<endl;*/
        }
        
        for(int i=0;i<p;i++){
            int x,y;
            cin >> x>> y;
            y = m - y - 1;
            cout << origami[x + y * n] <<endl;
        }
        
        //cout<< ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3144