#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);   
    Int w, h, t, p;
    Int d[30] = {};
    Int c[30] = {};
    Int x[50] = {};
    Int y[50] = {};
    Int field[50][50] = {};
    while (true) {
        cin >> w >> h >> t >> p;
        Int w1 = 0;
        Int w2 = w;
        Int h1 = 0;
        Int h2 = h;
        if (w == 0) break;
        bool rev_w = false;
        bool rev_h = false;
        for (Int i = h1; i < h2; i++) {
            for (Int j = w1; j < w2; j++) {
                field[i][j] = 1;
            }
        }
        for (Int i = 0; i < t; i++) cin >> d[i] >> c[i];
        for (Int i = 0; i < p; i++) cin >> x[i] >> y[i];
        for (Int i = 0; i < t; i++) {
            if (d[i] == 1) {
                if (rev_w) c[i] = w2 - w1 - c[i];
                if (c[i] <= w2 - w1 - c[i]) {
                    rev_w = false;
                    w1 += c[i];
                    for (Int k = h1; k < h2; k++) {
                        for (Int j = 0; j < c[i]; j++) {
                            field[k][w1 + j] += field[k][w1 - 1 - j];
                        }
                    }
                }
                else {
                    rev_w = true;
                    Int x = w2 - w1 - c[i];
                    w2 -= x;
                    for (Int k = h1; k < h2; k++) {
                        for (Int j = 0; j < x; j++) {
                            field[k][w2 - 1 - j] += field[k][w2 + j];
                        }
                    }
                }
            }
            else {
                if (rev_h) c[i] = h2 - h1 - c[i];
                if (c[i] <= h2 - h1 - c[i]) {                    
                    rev_h = false;
                    h2 -= c[i];
                    for (Int k = w1; k < w2; k++) {
                        for (Int j = 0; j < c[i]; j++) {
                            field[h2 - 1 - j][k] += field[h2 + j][k];
                        }
                    }
                }
                else {
                    rev_h = true;
                   //  dump("MO");
                    Int x = h2 - h1 - c[i];
                    h1 += x;
                    for (Int k = w1; k < w2; k++) {
                        for (Int j = 0; j < x; j++) {
                            field[h1 + j][k] += field[h1 - 1 - j][k];
                        }
                    }
                }
            }
            /* for (Int i = h1; i < h2; i++) {
                for (Int j = w1; j < w2; j++) {
                    cout << field[i][j] << " ";
                }
                cout << endl;
            } */
        }
        
        for (Int i = 0; i < p; i++) {
            Int a = !rev_h ? h2 - 1 - y[i] : h1 + y[i];
            Int b = !rev_w ? w1 + x[i] : w2 - 1 - x[i];
            dump(field[a][b]);
        }
       /*  cout << endl;
        for (Int i = h1; i < h2; i++) {
            for (Int j = w1; j < w2; j++) {
                cout << field[i][j] << " ";
            }
            cout << endl;
        }
        cout << endl; */
    }
    return 0;
}


Measured memory_bytes: 3224