#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
#define ll long long int
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1;} return 0;}
//vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
using namespace std;
int main(int argc, char const *argv[]) {
    int n,m,t,p;
    int tmp[2][101][101];
    while (cin >> n >> m >> t >> p, n || m || t || p)
    {
        rep(i,2){
            rep(j,101){
                rep(k,101){
                    tmp[i][j][k] = 0;
                }
            }
        }
        rep(y,m){
            rep(x,n){
                tmp[0][y][x] = 1;
            }
        }
        int d, c;
        rep(i,t){
            cin >> d >> c;
            rep(y,101){
                rep(x,101){
                    tmp[(i + 1) % 2][y][x] = 0;
                }
            }
            if(d==1){
                rep(y, m)
                {
                    rep(x, n)
                    {
                        tmp[(i + 1) % 2][y][x] = tmp[i % 2][y][x+c];
                    }
                }
                rep(x,c){
                    rep(y,m){
                        tmp[(i + 1) % 2][y][x] += tmp[i % 2][y][c-x-1];
                    }
                }
            }
            else{
                rep(y, m)
                {
                    rep(x, n)
                    {
                        tmp[(i + 1) % 2][y][x] = tmp[i % 2][y+c][x];
                    }
                }
                rep(x, n)
                {
                    rep(y, c)
                    {
                        tmp[(i + 1) % 2][y][x] += tmp[i % 2][c-y-1][x];
                    }
                }
            }

        }
        int x, y;
        rep(i,p){
            cin >> x >> y;
            cout <<tmp[t%2][y][x] << endl;
        }
    }
    return 0;
}

