#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m, t, i;
  bool c;
  cin >> n >> k >> m >> t;
  for (int j = 1; j <= t; j++) {
    cin >> c >> i;
    if (c == 0) {
      if (k > i) {
        n -= i;
        k -= i;
        cout << n << " " << k << endl;
      } else {
        n = i;
        cout << n << " " << k << endl;
      }
    } else {
      if (k >= i) k++;
      n++;
      cout << n << " " << k << endl;
    }
  }
}
