#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

int n, m, t, p;
int o[1000][1000];

void solve() {
    memset(o, 0, sizeof(o));
    rep(i,m) rep(j,n) o[i][j] = 1;
    int h = 0, w = 0;
    rep(i,t) {
        int d, c; cin >> d >> c;
        if (d == 1) {
            rep(j,1000) {
                rep(k,c) {
                    o[j][w+2*c-1-k] += o[j][w+k];
                }
            }
            w += c;
        } else {
            rep(j,1000) {
                rep(k,c) {
                    o[h+2*c-1-k][j] += o[h+k][j];
                }
            }
            h += c;
        }
    }
    rep(i,p) {
        int x, y; cin >> x >> y;
        cout << o[h+y][w+x] << endl;
    }
}

int main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
    cout.precision(20);
    cerr << fixed;
    cerr.precision(6);
#ifdef LOCAL
    //freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif  
    while (cin >> n >> m >> t >> p) {
        if (n == 0 && m == 0 && t == 0 && p == 0) break;
        solve();
    }
    //cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

