#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n, m, t, p; cin >> n >> m >> t >> p;
    if (!n) break;
    VV<> a(n, V<>(m, 1));
    while (t--) {
      int d, c; cin >> d >> c;
      if (d == 1) {
        VV<> na(max(c, n - c), V<>(m));
        for (int j = 0; j < m; ++j) {
          for (int i = 0; i < n - c; ++i) na[i][j] += a[c + i][j];
          for (int i = 0; i < c; ++i) na[i][j] += a[c + ~i][j];
        }
        swap(a, na);
        n = a.size();
      } else {
        VV<> na(n, V<>(max(c, m - c)));
        for (int i = 0; i < n; ++i) {
          for (int j = 0; j < m - c; ++j) na[i][j] += a[i][c + j];
          for (int j = 0; j < c; ++j) na[i][j] += a[i][c + ~j];
        }
        swap(a, na);
        m = a[0].size();
      }
    }
    while (p--) {
      int x, y; cin >> x >> y;
      cout << a[x][y] << '\n';
    }
  }
}
