#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, m, n, t, k;
  cin >> n >> k >> m >> t;
  while (t--) {
    cin >> a >> b;
    if (a == 0) {
      if (b < k)
        k -= b, n -= b;
      else
        n = b;
    } else {
      if (b <= k)
        k++, n++;
      else
        n++;
    }
    n = min(n, m);
    cout << n << " " << k << "\n";
  }
  return 0;
}
