#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1)
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 34
//---------------------

int n,m,t,p,d[20],c[20],x[20],y[20];
int data[MAXN][MAXN];
int p1x,p1y,p2x,p2y;

int w(){
    return p2x-p1x+1;
}
int h(){
    return p2y-p1y+1;
}

int mirId(int a,int m){
    return 2*m-a-1;
}

void flipLR(){
    int memo[50];
    FORE(j,p1y,p2y){
        FORE(i,p1x,p2x){
            memo[i]=data[i][j];
        }
        FORE(i,p1x,p2x){
            data[p2x-(i-p1x)][j]=memo[i];
        }
    }
}

void flipUB(){
    int memo[50];
    FORE(i,p1x,p2x){
        FORE(j,p1y,p2y){
            memo[j]=data[i][j];
        }
        FORE(j,p1y,p2y){
            data[i][p2y-(j-p1y)]=memo[j];
        }
    }
}

void lr(int num){
    if(num<=(w()>>1)){
        FOR(i,0,num){
            FOR(j,0,h()){
                data[p1x+mirId(i,num)][j+p1y]+=data[i+p1x][j+p1y];
            }
        }
        p1x+=num;
    }else{
        num=w()-num;
        FOR(i,0,num){
            FOR(j,0,h()){
                data[p2x-mirId(i,num)][j+p1y]+=data[p2x-i][j+p1y];
            }
        }
        p2x-=num;
        flipLR();
    }
}

void ud(int num){
    if(num<=(h()>>1)){
        FOR(i,0,w()){
            FOR(j,0,num){
                data[i+p1x][p1y+mirId(j,num)]+=data[i+p1x][j+p1y];
            }
        }
        p1y+=num;
    }else{
        num=h()-num;
        FOR(i,0,w()){
            FOR(j,0,num){
                data[i+p1x][p2y-mirId(j,num)]+=data[i+p1x][p2y-j];
            }
        }
        p2y-=num;
        flipUB();
    }
}

bool init(){
    ZERO(d);ZERO(c);ZERO(data);ZERO(x);ZERO(y);
    cin>>n>>m>>t>>p;

    if(n<=0) return false;

    REP(i,t) cin>>d[i]>>c[i];
    REP(i,p) cin>>x[i]>>y[i];

    REP2D1(i,j,n,m) data[i][j] = 1;

    p1x=p1y=1;
    p2x=n;
    p2y=m;

    return true;
}

int main()
{
    while(init()){
        REP(i,t){
            if(d[i]==1){
                lr(c[i]);
            }else{
                ud(c[i]);
            }
        }
        REP(i,p)
        cout<< data[p1x+x[i]][p1y+y[i]] <<endl;
    }
    return 0;
}



Measured memory_bytes: 3104