#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);

    int n,m,t,p;
    vector<int> ans;
    while(cin>>n>>m>>t>>p){
        if(n==0) break;
        vector<int> h(50000),w(50000);
        for(int i=0;i<m;i++) h[i] = 1;
        for(int i=0;i<n;i++) w[i] = 1;
        int dd,c;
        int l=0,d=0;
        for(int i=0;i<t;i++){
            cin>>dd>>c;
            if(dd==1){
                for(int j=1;j<=c;j++){
                    w[l+c+j-1] += w[l+c-j];
                }
                l+=c;
            }
            else {
                for(int j=1;j<=c;j++){
                    h[d+c+j-1] += h[d+c-j];
                }
                d+=c;
            }
        }
        
        
        int x,y;
        for(int i=0;i<p;i++){
            cin >> x >> y;
            cout << h[d+y] * w[l+x] << endl;;
            ans.push_back( h[d+y] * w[l+x]  );
        }
    }
    //cerr<<endl;
    //for(auto i:ans) cerr<<i<<endl;
    
    
    
}
