#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;

int main(void){
    while (1) {
        int n, m, t, p;
        cin >> n >> m >> t >> p;
        
        if (n == 0 && m == 0 && t == 0 && p == 0) return 0;
        
        int pile[35][35];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) pile[i][j] = 1;
        }
        
        for (int i = 0; i < t; i++) {
            int d, c;
            cin >> d >> c;
            
            if (d == 1) {
                if (c <= n - c) {
                    for (int j = 0; j < c; j++) {
                        for (int k = 0; k < m; k++) {
                            pile[k][c + j] += pile[k][c - j - 1];
                        }
                    }
                    for (int j = 0; j < n - c; j++) {
                        for (int k = 0; k < m; k++) {
                            pile[k][j] = pile[k][c + j];
                        }
                    }
                    n -= c;
                }
                else {
                    for (int j = 0; j < n - c; j++) {
                        for (int k = 0; k < m; k++) {
                            pile[k][c - j - 1] += pile[k][c + j];
                        }
                    }
                    int tmp[35][35];
                    for (int j = 0; j < c; j++) {
                        for (int k = 0; k < m; k++) {
                            tmp[k][j] = pile[k][c - j - 1];
                        }
                    }
                    for (int j = 0; j < c; j++) {
                        for (int k = 0; k < m; k++) {
                            pile[k][j] = tmp[k][j];
                        }
                    }
                    n -= n - c;
                }
            }
            else {
                if (c <= m - c) {
                    for (int j = 0; j < c; j++) {
                        for (int k = 0; k < n; k++) {
                            pile[c + j][k] += pile[c - j - 1][k];
                        }
                    }
                    for (int j = 0; j < m - c; j++) {
                        for (int k = 0; k < n; k++) {
                            pile[j][k] = pile[c + j][k];
                        }
                    }
                    m -= c;
                }
                else {
                    for (int j = 0; j < m - c; j++) {
                        for (int k = 0; k < n; k++) {
                            pile[c - j - 1][k] += pile[c + j][k];
                        }
                    }
                    int tmp[35][35];
                    /*
                    for (int j = 0; j < c; j++) {
                        for (int k = 0; k < m; k++) {
                            tmp[k][j] = pile[k][c - j - 1];
                        }
                    }
                    for (int j = 0; j < c; j++) {
                        for (int k = 0; k < m; k++) {
                            pile[k][j] = tmp[k][j];
                        }
                    }*/
                    
                    for (int j = 0; j < c; j++) {
                        for (int k = 0; k < n; k++) {
                            tmp[j][k] = pile[c - j - 1][k];
                        }
                    }
                    for (int j = 0; j < c; j++) {
                        for (int k = 0; k < n; k++) {
                            pile[j][k] = tmp[j][k];
                        }
                    }
                    m -= m - c;
                }
            }
            
        }
        
        for (int i = 0; i < p; i++) {
            int x, y;
            cin >> x >> y;
            cout << pile[y][x] << endl;
        }
    }
}



Measured memory_bytes: 3092