#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, t, p;
	while (cin >> m >> n >> t >> p, n) {
		vvi v(n, vi(m, 1));
		REP(adfad, t) {
			int d, c;
			cin >> d >> c;
			if (d == 1) {
				int k = max(m - c, c);
				vvi t(n, vi(k));
				REP(i, n) {
					REP(j, k) {
						int tmp = 0;
						if (j < c)tmp += v[i][c - j - 1];
						if (c + j < m)tmp += v[i][c + j];
						t[i][j] = tmp;
					}
				}
				m = k;
				v = t;

			}
			else {
				int k = max(n - c, c);
				vvi t(k, vi(m));
				REP(i, k) {
					REP(j, m) {
						int tmp = 0;
						if (i < c)tmp += v[c - i - 1][j];
						if (i + c < n)tmp += v[c + i][j];
						t[i][j] = tmp;
					}
				}
				n = k;
				v = t;
			}
		}
		REP(i, p) {
			int x, y;
			cin >> x >> y;
			cout << v[y][x] << endl;
		}
	}
}
