#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    for(;;){
        int w, h, t, p;
        cin >> w >> h >> t >> p;
        if(w == 0)
            return 0;

        vector<vector<int> > v(h, vector<int>(w, 1));
        while(--t >= 0){
            int d, c;
            cin >> d >> c;

            int h2 = h;
            int w2 = w;
            int cy = 0;
            int cx = 0;
            if(d == 1){
                w2 = max(c, w - c);
                cx = c;
            }
            else{
                h2 = max(c, h - c);
                cy = c;
            }

            vector<vector<int> > v2(h2, vector<int>(w2, 0));
            for(int y=0; y<h; ++y){
                for(int x=0; x<w; ++x){
                    int y2 = abs(y * 2 - cy * 2 + 1) / 2;
                    int x2 = abs(x * 2 - cx * 2 + 1) / 2;
                    v2[y2][x2] += v[y][x];
                }
            }
            v = move(v2);
            h = h2;
            w = w2;
        }

        while(--p >= 0){
            int x, y;
            cin >> x >> y;
            cout << v[y][x] << endl;
        }
    }
}

