#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
using pii = pair<int, int>;
using vi = vector<int>;
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
int di[] = {0, 0, -1, 1, -1, 1, -1, 1}; //右、左、マイナス、プラス
int dj[] = {1, -1, 0, 0, -1, 1, 1, -1};
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
//manip
template<class T> bool chmax(T &a, T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, T &b) {if (a > b) {a = b; return 1;} return 0;}
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0






int main() {
    //cast caution
    //look constraints always
    cin.tie(0); ios::sync_with_stdio(false);
    
    
    
    
    
    
    
    
    int w, h, t, p;
    while (cin >> w && w) {
        cin >> h >> t >> p;
        int d[t], c[t];
        rep(i, t) cin >> d[i] >> c[i];
        int x[p], y[p];
        rep(i, p) cin >> x[i] >> y[i];
        
        int table[32 * 20][32 * 20];
        rep(i, 32 * 20) rep(j, 32 * 20) table[i][j] = 1;
        int table2[32 * 20][32 * 20];
        rep(i, 32 * 20) rep(j, 32 * 20) table2[i][j] = 1;
        //table2 -> table
        rep(i, t) {
            if (d[i] == 1) {
                int ol = min(c[i], w - c[i]); //overlap
                rep(j, ol) rep(k, h) table[k][j] = table2[k][c[i] + j] + table2[k][c[i] - 1 - j];
               
                int rest = w - 2 * ol;
                if (ol == c[i]) {
                    rep(j, rest) rep(k, h) table[k][ol + j] = table2[k][2 * c[i] + j];
                } else {
                    rep(j, rest) rep(k, h) table[k][ol + j] = table2[k][w - 1 - 2 * ol - j];
                }
                w -= ol;
            } else {
                //copy and paste
                int ol = min(c[i], h - c[i]); //overlap
                rep(k, ol) rep(j, w) table[k][j] = table2[c[i] + k][j] + table2[c[i] - 1 - k][j];
                
                /*
                if (i == 2) {
                    cout << endl; rep(k, h) {rep(j, w) cout << table[k][j] << " "; cout << endl;}
                    return 0;
                }
                */
                
                int rest = h - 2 * ol;
                if (ol == c[i]) {
                    rep(k, rest) rep(j, w) table[ol + k][j] = table2[2 * c[i] + k][j];
                } else {
                    rep(k, rest) rep(j, w) table[ol + k][j] = table2[h - 1 - 2 * ol - k][j];
                }
                h -= ol;
            }
            rep(j, h) rep(k, w) table2[j][k] = table[j][k];
            //cout << endl; rep(k, h) {rep(j, w) cout << table[k][j] << " "; cout << endl;}
        }
        rep(i, p) {
            cout << table[y[i]][x[i]] << endl;
        }
        
    }
    
    
    
    
    
    
    
    
    
    
    
}
//cast caution





Measured memory_bytes: 6276