#include <bits/stdc++.h>
using namespace std;

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

void printboard(int m, int n, const vector<vi> &paper) {
    cout << "--------------------------" << endl;
    cout << "Board:" << endl;
    for (int j = 0; j < m; j++) {
        for (int i = 0; i < n; i++) {
            cout << paper[i][j];
        }
        cout << endl;
    }
    cout << "--------------------------" << endl;
}

int main() {
    for (;;) {
        int n, m, t, p; cin >> n >> m >> t >> p; if (!n) break;
        vector<vi> paper(n, vi(m, 1));
            // printboard(m, n, paper);
        for (int i = 0; i < t; i++) {
            int d, c; cin >> d >> c;

            if (d == 1) {
                if (c * 2 > n) {
                    reverse(all(paper));
                    c = n - c;
                }

                for (int i = 0; i < c; i++) {
                    for (int j = 0; j < m; j++) {
                        paper[c + i][j] += paper[c - 1 - i][j];
                        paper[c - 1 - i][j] = 0;
                    }
                }
                paper = vector<vi>(paper.begin() + c, paper.end());

                n -= c;
            } else if (d == 2) {
                if (c * 2 > m) {
                    for (int i = 0; i < n; i++) reverse(all(paper[i]));
                    c = m - c;
                }
                for (int i = 0; i < n; i++) {

                    for (int j = 0; j < c; j++) {
                        paper[i][m - c - 1 - j] += paper[i][m - c + j];
                    }
                    paper[i] = vi(paper[i].begin(), paper[i].end() - c);
                }

                m -= c;
            }
            // printboard(m, n, paper);
        }
        int ans = 0;
        rep(i, 0, p) {
            // cout << n << " " << m << endl;
            int x, y; cin >> x >> y;
            cout << paper[x][m - 1 - y] << endl;
        }
    }
}


Measured memory_bytes: 3116