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