#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
template <class T1>
void deb(T1 e1) {
  cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
template <class T>
T gcd(const T a, const T b) {
  return (b ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(const T a, const T b) {
  return (a / gcd<T>(a, b) * b);
}
struct node {
  long long x, y;
  node() {}
  node(long long x, long long y) : x(x), y(y) {}
  bool operator<(const node& p) const { return x < p.x; }
};
vector<long long> fun(vector<long long> v, bool ck, long long j, long long id,
                      long long k) {
  if (ck) {
    vector<long long> p;
    for (long long i = 0; i < v.size(); i++) {
      if (i == j) {
        p.push_back(id);
      }
      p.push_back(v[i]);
    }
    if (j == v.size()) p.push_back(id);
    return p;
  } else {
    vector<long long> p, q;
    bool pk = 1;
    for (long long i = 0; i <= j; i++) {
      p.push_back(v[i]);
      if (v[i] == k) pk = 0;
    }
    for (long long i = j + 1; i < v.size(); i++) {
      q.push_back(v[i]);
    }
    if (!pk)
      return p;
    else
      return q;
  }
}
int main() {
  long long i, j, k, l, x, y, z, t, m, n, l1, l2;
  scanf("%lld %lld %lld %lld", &n, &k, &m, &t);
  vector<long long> v;
  for (i = 1; i <= n; i++) v.push_back(i);
  z = n;
  while (t--) {
    z++;
    scanf("%lld %lld", &x, &y);
    vector<long long> p = fun(v, x, y - 1, z, k);
    v.clear();
    l = 0;
    for (i = 0; i < p.size(); i++) {
      v.push_back(p[i]);
      if (p[i] == k) l = i + 1;
    }
    p.clear();
    deb(v.size(), l);
  }
  return 0;
}
