#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, n, m, t, p, d, c, x, y, k;
  while( 1 ) {
    scanf("%lld%lld%lld%lld", &n, &m, &t, &p);
    if(!n) break;
    ll a[n * (t + 1)][m * (t + 1)], ans = 0, now = 0, ox = 0, oy = 0, lx = n, ly = m;
    for(i = 0; i < n * (t + 1); ++i) for(j = 0; j < m * (t + 1); ++j) {
      if(i < n && j < m) a[i][j] = 1;
      else a[i][j] = 0;
    }
    for(k = 0; k < t; ++k) {
      scanf("%lld%lld", &d, &c);
      if(d == 1) {
        for(i = ox; i < c + ox; ++i) for(j = oy; j < ly; ++j) {
          a[2 * (c + ox) - i - 1][j] += a[i][j];
        }
        lx = lx > 2 * c + ox ? lx : 2 * c + ox, ox = ox + c;
      } else {
        for(i = oy; i < c + oy; ++i) for(j = ox; j < lx; ++j) {
          a[j][2 * (c + oy) - i - 1] += a[j][i];
        }
        ly = ly > 2 * c + oy ? ly : 2 * c + oy, oy = oy + c;
      }
    }
    for(i = 0; i < p; ++i) {
      scanf("%lld%lld", &x, &y);
      printf("%lld\n", a[ox + x][oy + y]);
    }
  }
  return 0;
}
