The Third Doctor Who once correctly said that travel between parallel universes is "like travelling sideways". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all know, there will never be more than 250.

Heidi recently got her hands on a multiverse observation tool. She was able to see all n universes lined up in a row, with non-existent links between them. She also noticed that the Doctor was in the k-th universe.

The tool also points out that due to restrictions originating from the space-time discontinuum, the number of universes will never exceed m.

Obviously, the multiverse is unstable because of free will. Each time a decision is made, one of two events will randomly happen: a new parallel universe is created, or a non-existent link is broken.

More specifically, 

  * When a universe is created, it will manifest itself between any two adjacent universes or at one of the ends. 
  * When a link is broken, it could be cut between any two adjacent universes. After separating the multiverse into two segments, the segment NOT containing the Doctor will cease to exist. 



Heidi wants to perform a simulation of t decisions. Each time a decision is made, Heidi wants to know the length of the multiverse (i.e. the number of universes), and the position of the Doctor.

Input

The first line contains four integers n, k, m and t (2 ≤ k ≤ n ≤ m ≤ 250, 1 ≤ t ≤ 1000).

Each of the following t lines is in one of the following formats: 

  * "1 i" — meaning that a universe is inserted at the position i (1 ≤ i ≤ l + 1), where l denotes the current length of the multiverse. 
  * "0 i" — meaning that the i-th link is broken (1 ≤ i ≤ l - 1), where l denotes the current length of the multiverse. 

Output

Output t lines. Each line should contain l, the current length of the multiverse and k, the current position of the Doctor.

It is guaranteed that the sequence of the steps will be valid, i.e. the multiverse will have length at most m and when the link breaking is performed, there will be at least one universe in the multiverse.

Example

Input


5 2 10 4
0 1
1 1
0 4
1 2


Output


4 1
5 2
4 2
5 3

Note

The multiverse initially consisted of 5 universes, with the Doctor being in the second.

First, link 1 was broken, leaving the multiverse with 4 universes, and the Doctor in the first.

Then, a universe was added to the leftmost end of the multiverse, increasing the multiverse length to 5, and the Doctor was then in the second universe.

Then, the rightmost link was broken.

Finally, a universe was added between the first and the second universe.
#include <bits/stdc++.h>
using namespace std;
long long add(long long a, long long b, long long mod) {
  return (a % mod + b % mod) % mod;
}
long long sub(long long a, long long b, long long mod) {
  return (a % mod - b % mod + mod) % mod;
}
long long mul(long long a, long long b, long long mod) {
  return (a % mod * b % mod) % mod;
}
long long sumodd(long long num, long long mod) { return mul(num, num, mod); }
long long sumeven(long long num, long long mod) {
  return mul(num, num + 1, mod);
}
long long sumrange(long long st, long long en, long long num) {
  return (num * (st + en) / 2);
}
long long gcd(long long a, long long b) {
  while (b != 0) {
    long long a2 = a;
    a = b;
    b = a2 % b;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
string makeitbinary(long long n) {
  string s;
  while (n) {
    s = s + (char)((n % 2) + '0');
    n /= 2;
  }
  reverse(s.begin(), s.end());
  return s;
}
bool bit(int num, int i) { return ((num >> i) & 1); }
long long fastpowermod(long long b, long long p, long long mod) {
  long long ans = 1;
  while (p) {
    if (p % 2) {
      ans = mul(ans, b, mod);
    }
    b = mul(b, b, mod);
    p /= 2;
  }
  return ans;
}
long long fastpower(long long b, long long p) {
  long long ans = 1;
  while (p) {
    if (p % 2) {
      ans = ans * b;
    }
    b = b * b;
    p /= 2;
  }
  return ans;
}
double fastpower_double(double b, long long p) {
  double ans = 1;
  while (p) {
    if (p % 2) {
      ans = ans * b;
    }
    b = b * b;
    p /= 2;
  }
  return ans;
}
long long summation_formula(long long n) { return (n * (n + 1) / 2); }
bool lower_vowel(char c) {
  return (c == 'i' || c == 'o' || c == 'u' || c == 'a' || c == 'e');
}
string bigint_mini(string s1, string s2) {
  if (s1.size() > s2.size()) {
    return s2;
  } else if (s2.size() > s1.size()) {
    return s1;
  }
  for (int i = 0; i < s1.size(); i++) {
    if ((s1[i] - '0') > (s2[i] - '0')) {
      return s2;
    } else if ((s2[i] - '0') > (s1[i] - '0')) {
      return s1;
    }
  }
  return s1;
}
double polygon_area(int n, vector<double> X, vector<double> Y) {
  double area = 0.0;
  int j = n - 1;
  for (int i = 0; i < n; i++) {
    area += (X[j] + X[i]) * (Y[j] - Y[i]);
    j = i;
  }
  return abs(area / 2.0);
}
long long sum_of_digits(string s) {
  long long sum = 0;
  for (int i = 0; i < s.size(); i++) {
    sum += s[i] - '0';
  }
  return sum;
}
string makeitbase(long long num, long long base) {
  string s;
  while (num) {
    long long mod = num % base;
    s += (mod + '0');
    num /= base;
  }
  reverse(s.begin(), s.end());
  return s;
}
bool intersect(long long l1, long long r1, long long l2, long long r2) {
  return (max(l1, l2) <= min(r1, r2));
}
pair<long long, long long> find_intersection(long long l1, long long r1,
                                             long long l2, long long r2) {
  return {max(l1, l2), min(r1, r2)};
}
long long sum_ranges(long long l, long long r) {
  return summation_formula(r) - summation_formula(l);
}
double power_2(double num) { return num * num; }
struct point {
  int x, y;
};
long long dist(point p1, point p2) {
  return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);
}
bool square(point p1, point p2, point p3, point p4) {
  long long d2 = dist(p1, p2);
  long long d3 = dist(p1, p3);
  long long d4 = dist(p1, p4);
  if (d2 == d3 && 2 * d2 == d4 && 2 * dist(p2, p4) == dist(p2, p3)) {
    return true;
  }
  if (d3 == d4 && 2 * d3 == d2 && 2 * dist(p3, p2) == dist(p3, p4)) {
    return true;
  }
  if (d2 == d4 && 2 * d2 == d3 && 2 * dist(p2, p3) == dist(p2, p4)) {
    return true;
  }
  return false;
}
const int sz = 1e6 + 1;
long long M = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, k, m, t;
  cin >> n >> k >> m >> t;
  while (t--) {
    int x, y;
    cin >> x >> y;
    if (x == 1) {
      if (y <= k) {
        k++;
      }
      n++;
    } else {
      if (k >= 1 && k <= y) {
        n -= (n - y);
      } else {
        n -= y;
        k -= y;
      }
    }
    cout << n << " " << k << endl;
  }
  return 0;
}
