#include <bits/stdc++.h>
using namespace std;
bool isp[200005];
void sv() {
  long long i, j;
  memset(isp, true, sizeof(isp));
  isp[1] = false;
  for (i = 2; i * i < 200005; i++) {
    if (isp[i]) {
      for (j = i * i; j < 200005; j += i) isp[j] = false;
    }
  }
}
long long powr(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long n, k, m, t, i, j;
void cut(long long y) {
  if (k <= y) {
    n = y;
  } else {
    n -= y;
    k -= y;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k >> m >> t;
  while (t--) {
    long long x, y;
    cin >> x >> y;
    if (!x) {
      cut(y);
    } else {
      n++;
      if (y <= k) k++;
      if (n > m) cut(n);
    }
    cout << n << " " << k << "\n";
  }
  return 0;
}
