#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  while (true) {
    int n, m, t, p;
    cin >> n >> m >> t >> p;
    if (n == 0)
      break;
    int size = 2000;
    vector<vector<int>> mp(size, vector<int>(size));
    int h = 1000, w = 1000;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        mp[i + h][j + w] = 1;
    for (int i = 0; i < t; i++) {
      int d, c;
      cin >> d >> c;
      if (d == 1) {
        for (int j = 0; j < size; j++) {
          for (int k = 0; h + c - k - 1 >= 0 && h + c + k < size; k++) {
            if (mp[h + c + k][j] + mp[h + c - k - 1][j] == 0)
              break;
            mp[h + c + k][j] += mp[h + c - k - 1][j];
            mp[h + c - k - 1][j] = 0;
          }
        }
        if (n > c * 2) {
          n = n - c;
        } else {
          n -= n - c;
        }
        h += c;
      } else {
        c = m - c;
        for (int j = 0; j < size; j++) {
          for (int k = 0; w + c - k - 1 >= 0 && w + c + k < size; k++) {
            if (mp[j][w + c - k - 1] + mp[j][w + c + k] == 0)
              break;
            mp[j][w + c - k - 1] += mp[j][w + c + k];
            mp[j][w + c + k] = 0;
          }
        }
        if (m > c * 2) {
          w -= m - 2 * c;
          m = m - c;
        } else {
          m -= m - c;
        }
      }
    }
    for (int i = 0; i < p; i++) {
      int x, y;
      cin >> x >> y;
      y = m - y - 1;
      cout << mp[x + h][y + w] << endl;
    }
  }
  return 0;
}
