#include <bits/stdc++.h>

#define rep(i, j, k) for(int i = j; i < k; i++)
#define rrep(i, j, k) for(int i = j; i > k; i--)


using namespace std;


void sol(int &n, int &m, int &t, int &p) {
    int now[40][40];
    int w = n, h = m;
    rep(i, 0, h) rep(j, 0, w) now[i][j] = 1;
    // rep(i, 0, h) {
    //     rep(j, 0, w) {
    //         cerr << now[i][j] << " ";
    //     }
    //     cerr << endl;
    // }
    //cerr << "hi" << endl;
    for (int tt = 0; tt < t; tt++) {
        int tmp[40][40];
        rep(i, 0, 40) rep(j, 0, 40) tmp[i][j] = 0;        
        int d, c; cin >> d >> c;
        //cerr << "(h, w) = " << h << " " << w << endl;
        if (d == 1) {
            for (int i = 0; i < h; i++) {
                int idx = 0;
                for (int j = c - 1; j >= 0; j--) {
                    tmp[i][idx] += now[i][j];
                    idx++;
                }
            }
        //     for (int i = 0; i < h; i++) {
        //     for (int j = 0; j < w; j++) {
        //         cerr << tmp[i][j] << " ";
        //     }
        //     cerr << endl;
        // }
            for (int i = 0; i < h; i++) {
                int idx = 0;
                for (int j = c; j < w; j++) {
                    tmp[i][idx] += now[i][j];
                    idx++;
                }
            }
        //     for (int i = 0; i < h; i++) {
        //     for (int j = 0; j < w; j++) {
        //         cerr << tmp[i][j] << " ";
        //     }
        //     cerr << endl;
        // }
            w = max(c, w - c);
        } else {
            if (h - c >= c) {
                for (int j = 0; j < w; j++) {
                    int idx = 0;
                    for (int i = 0; i < h - c; i++) {
                        tmp[idx][j] += now[i][j];
                        idx++;
                    }
                }
                for (int j = 0; j < w; j++) {
                    int idx = h - c - 1;
                    for (int i = h - c; i < h; i++) {
                        tmp[idx][j] += now[i][j];
                        idx--;
                    }
                }
            } else {
                for (int j = 0; j < w; j++) {
                    int idx = 0;
                    for (int i = h - 1; i >= h - c; i--) {
                        tmp[idx][j] += now[i][j];
                        idx++;
                    }
                }
                for (int j = 0; j < w; j++) {
                    int idx = c - 1;
                    for (int i = h - c - 1; i >= 0; i--) {
                        tmp[idx][j] += now[i][j];
                        idx--;
                    }
                }
            }
            h = max(c, h - c);
            //rep(i, 0, 40) rep(j, 0, 40) now[i][j] = tmp[i][j];
        }
        // for (int i = 0; i < h; i++) {
        //     for (int j = 0; j < w; j++) {
        //         cerr << now[i][j] << " ";
        //     }
        //     cerr << endl;
        // }
            rep(i, 0, 40) rep(j, 0, 40) now[i][j] = tmp[i][j];
    }
    //cerr << "hi" << endl;
    int ans = 0;
    for (int tt = 0; tt < p; tt++) {
        int x, y; cin >> x >> y;
        y = h - 1 - y;
        cout << now[y][x] << endl;
    }
    //cerr << "hi" << endl;
}

int n, m, t, p;

int main() {
    while (cin >> n >> m >> t >> p, n) {
        sol(n, m, t, p);
    }
}



Measured memory_bytes: 3088