#include <bits/stdc++.h>
using namespace std;
int const M = 1e5 + 10, M2 = 1e5 + 10, mod = 998244353, inf = 1e9 + 10;
int32_t main() {
  int n, m, w, t;
  cin >> n >> w >> m >> t;
  while (t--) {
    int q, x;
    cin >> q >> x;
    if (q == 1) {
      n++;
      if (x <= w) w++;
    }
    if (q == 0) {
      if (x < w) {
        w -= x;
        n -= x;
      } else {
        n = x;
      }
    }
    cout << n << " " << w << endl;
  }
}
