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 \le k \le n \le m \le 250$, $1 \le t \le 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 \le i \le l + 1$), where $l$ denotes the current length of the multiverse.  "$0$ $i$" — meaning that the $i$-th link is broken ($1 \le i \le 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.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Implementation


Solutions:
r = lambda : map(int, input().split())
(n, k, m, t) = list(r())
tab = [0] * n
tab[k - 1] = 1
command = []
for i in range(t):
	command.append(list(r()))
res = []
for i in range(t):
	if command[i][0] == 0:
		try:
			tab.index(1, 0, command[i][1])
			tab = tab[0:command[i][1]]
		except ValueError:
			tab = tab[command[i][1]:len(tab)]
	else:
		tab.insert(command[i][1] - 1, 0)
	res.append([len(tab), tab.index(1) + 1])
for i in range(t):
	print(res[i][0], res[i][1])


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, k, m, t) = map(int, input().split())
	l = n
	for i in range(t):
		(op, p) = map(int, input().split())
		if op == 0:
			if p < k:
				l = l - p
				k = k - p
			else:
				l = p
		else:
			l += 1
			if p <= k:
				k += 1
		print(l, k)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(lengte, dokter, _, t) = map(int, input().split())
for _ in range(t):
	(x, b) = map(int, input().split())
	if x == 1:
		if b < dokter + 1:
			dokter += 1
		lengte += 1
	elif b < dokter:
		dokter -= b
		lengte -= b
	else:
		lengte -= lengte - b
	print(lengte, dokter)


(n, doc, m, t) = map(int, input().split())
for _ in range(t):
	(chk, idx) = map(int, input().split())
	if chk == 1:
		n += 1
		if idx <= doc:
			doc += 1
	elif idx < doc:
		doc -= idx
		n -= idx
	else:
		n = idx
	print(n, doc)


(n, k, m, t) = list(map(int, input().split()))
l = n
for i in range(t):
	(a, b) = list(map(int, input().split()))
	if a == 0:
		if b < k:
			l = l - b
			k = k - b
		else:
			l = b
	else:
		l += 1
		if b <= k:
			k += 1
	print(l, k)


(n, pos, maxx, que) = list(map(int, input().split()))
initial = [1] * n
for x in range(que):
	(a, b) = list(map(int, input().split()))
	if a == 1:
		lam = b
		if pos < lam:
			pass
		else:
			pos += 1
		initial.insert(lam - 1, 1)
		n += 1
		print(n, pos)
	else:
		jam = b
		ham = b + 1
		if pos <= jam:
			initial = initial[0:jam]
			n = len(initial)
		else:
			initial = initial[ham - 1:]
			n = len(initial)
			pos -= jam
		print(n, pos)


(n, k, m, t) = map(int, input().split())
for _ in range(t):
	(x, y) = map(int, input().split())
	if x:
		n += 1
		if y <= k:
			k += 1
	elif y < k:
		k -= y
		n -= y
	else:
		n = y
	print(n, k)


import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor
from copy import deepcopy
from itertools import accumulate
from collections import Counter
import math
from functools import reduce
from bisect import bisect_right
sys.setrecursionlimit(200000)
input = sys.stdin.readline

def ii():
	return int(input())

def mi():
	return map(int, input().rstrip().split())

def lmi():
	return list(map(int, input().rstrip().split()))

def li():
	return list(input().rstrip())

def debug(x):
	print('debug: ', x, file=sys.stderr)

def main():
	(n, k, m, t) = mi()
	ans = [k - 1, n - k]
	for i in range(t):
		(c, i) = mi()
		if c == 1:
			if i <= ans[0] + 1:
				ans[0] += 1
			else:
				ans[1] += 1
		elif i <= ans[0]:
			ans[0] -= i
		else:
			ans[1] = i - ans[0] - 1
		print(sum(ans) + 1, ans[0] + 1)

def __starting_point():
	main()
__starting_point()


from sys import stdin
from bisect import bisect_right as br
input = stdin.readline
(n, k, m, t) = list(map(int, input().split()))
ans = [0] * n
ans[k - 1] = 1
for i in range(t):
	(d, u) = list(map(int, input().split()))
	if d == 0:
		a = ans[:u]
		b = ans[u:]
		if 1 in a:
			print(len(a), a.index(1) + 1)
			ans = a[:]
		else:
			print(len(b), b.index(1) + 1)
			ans = b[:]
	else:
		ans = ans[:u - 1] + [0] + ans[u - 1:]
		print(len(ans), ans.index(1) + 1)


from sys import stdin, stdout
input = stdin.readline
(n, k, m, t) = map(int, input().split(' '))
for tc in range(t):
	(choose, time) = map(int, input().split())
	if choose == 0:
		if time >= k:
			n = time
		else:
			n -= time
			k -= time
	elif time > k:
		n += 1
	else:
		n += 1
		k += 1
	print(n, k)


(n, d, m, t) = map(int, input().split())
for i in range(t):
	(a, b) = map(int, input().split())
	if a:
		n += 1
		if d >= b:
			d += 1
	elif d <= b:
		n = b
	else:
		n -= b
		d -= b
	print(n, d)


def main():
	(n, k, m, t) = map(int, input().split())
	multi = [0] * n
	multi[k - 1] = 1
	for i in range(t):
		(op, index) = map(int, input().split())
		if op == 1:
			if k >= index:
				k += 1
			multi.insert(index - 1, 0)
		elif k > index:
			k -= index
			multi = multi[index:]
		else:
			multi = multi[:index]
		print(len(multi), k)
main()


(n, k, m, t) = map(int, input().split())
for i in range(t):
	(type, i) = map(int, input().split())
	if type:
		n += 1
		if k >= i:
			k += 1
	elif k >= i + 1:
		k -= i
		n -= i
	else:
		n = i
	print(n, k)


(n, k, m, t) = [int(i) for i in input().split()]
k -= 1
for i in range(t):
	(a, x) = [int(i) for i in input().split()]
	if a == 0:
		if x > k:
			n = x
		else:
			n -= x
			k -= x
	else:
		x -= 1
		if x <= k:
			k += 1
		n += 1
	print(n, k + 1)


(n, k, m, t) = map(int, input().strip().split())
for _ in range(t):
	(operation, index) = map(int, input().strip().split())
	if operation == 0:
		if index < k:
			n -= index
			k -= index
		else:
			n -= n - index
	else:
		if index <= k:
			k += 1
		n += 1
	print(n, k)


from math import *
(n, d, lim, t) = map(int, input().split(' '))
a = [0] * n
a[d - 1] = 1
for _ in range(t):
	(w, pos) = map(int, input().split(' '))
	if w == 1:
		if len(a) < lim:
			a.insert(pos - 1, 0)
	else:
		l1 = a[:pos]
		l2 = a[pos:]
		if l1.count(1) > 0:
			a = l1
		else:
			a = l2
	indx = 0
	for i in range(len(a)):
		if a[i] == 1:
			indx = i + 1
			break
	print(len(a), indx)


(l, k, m, t) = map(int, input().split())
for i in range(t):
	(x, y) = map(int, input().split())
	if x == 1:
		if y <= k:
			k += 1
		l += 1
	elif y < k:
		l -= y
		k -= y
	else:
		l -= l - y
	print(l, k)


(n, k, m, t) = map(int, input().split())
for i in range(t):
	(a, b) = map(int, input().split())
	if a:
		if b <= k and n + 1 <= m:
			k += 1
			n += 1
		elif b > k and n + 1 <= m:
			n += 1
	elif b < k:
		k -= b
		n -= b
	elif b >= k:
		n -= n - b
	print(n, k)


def naiveSolve():
	return

def main():
	(n, k, m, t) = readIntArr()
	right = n
	allans = []
	for _ in range(t):
		(insertBroken, pos) = readIntArr()
		if insertBroken == 1:
			right += 1
			if pos <= k:
				k += 1
		elif pos + 1 <= k:
			k -= pos
			right -= pos
		else:
			right = pos
		allans.append([right, k])
	multiLineArrayOfArraysPrint(allans)
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(r):
	print('? {}'.format(r))
	sys.stdout.flush()
	return readIntArr()

def answerInteractive(adj, n):
	print('!')
	for u in range(1, n + 1):
		for v in adj[u]:
			if v > u:
				print('{} {}'.format(u, v))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
from math import gcd, floor, ceil
for _abc in range(1):
	main()


import sys
import os
from io import IOBase, BytesIO

def main():
	(n, k, m, t) = get_ints()
	(left, right) = (1, n)
	for _ in range(t):
		(x, y) = get_ints()
		if x == 0:
			if k <= y:
				right = y
				print(right - left + 1, k)
			else:
				k = k - y
				right -= y
				print(right - left + 1, k)
		else:
			right += 1
			if y <= k:
				k += 1
			print(right - left + 1, k)
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		py2 = round(0.5)
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2 == 1:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def get_array():
	return links(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().strip()
main()


(n, k, m, t) = map(int, input().split())
for i in range(t):
	(bj, p) = map(int, input().split())
	if bj == 0:
		n1 = p
		n2 = n - p
		if k > p:
			n = n2
			k = k - p
		elif k <= p:
			n = n1
	elif bj == 1:
		if k >= p:
			k = k + 1
			n = n + 1
		elif k < p:
			n = n + 1
	print(n, k, sep=' ')


nkmt = [int(k) for k in input().split()]
n = nkmt[0]
k = nkmt[1]
m = nkmt[2]
t = nkmt[3]
arr_d = []
uni = [0] * n
uni[k - 1] = 1
for _ in range(t):
	i = [int(k) for k in input().split()]
	if i[0] == 1:
		uni.insert(i[1] - 1, 0)
	if i[0] == 0:
		uni_temp1 = uni[:i[1]]
		uni_temp2 = uni[i[1]:]
		if 1 in uni_temp1:
			uni = uni_temp1
		else:
			uni = uni_temp2
	print(len(uni), end=' ')
	print(uni.index(1) + 1)


(n, k, m, t) = [int(i) for i in input().split()]
temp = n
for j in range(t):
	(x, y) = [int(i) for i in input().split()]
	if x == 0:
		if y < k:
			(temp, k) = (temp - y, k - y)
		else:
			temp = y
	else:
		temp += 1
		if y <= k:
			k += 1
	print(temp, k)


(n, k, m, t) = map(int, input().split(' '))
universe = [1 for i in range(n)]
for _ in range(t):
	(op, position) = map(int, input().split(' '))
	if op == 0:
		if len(universe) == 1:
			continue
		if k <= position:
			for i in range(position, len(universe)):
				universe[i] = 0
			universe = [v for v in universe if v != 0]
			print(len(universe), k)
		else:
			for i in range(position):
				universe[i] = 0
			universe = [v for v in universe if v != 0]
			k -= position
			print(len(universe), k)
	elif op == 1:
		if len(universe) == m:
			continue
		universe.insert(position - 1, 1)
		if position <= k:
			k += 1
			print(len(universe), k)
		else:
			print(len(universe), k)


(n, k, m, t) = map(int, input().split(' '))
pos_doctor = k
num_universe = n
for i in range(t):
	(s1, s2) = map(int, input().split(' '))
	if s1 == 1:
		num_universe += 1
		if s2 <= pos_doctor:
			pos_doctor += 1
	elif s2 < pos_doctor:
		pos_doctor -= s2
		num_universe -= s2
	else:
		num_universe = s2
	print(num_universe, pos_doctor)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
(n, k, m, t) = mapin()
for _ in range(t):
	(tt, i) = mapin()
	if tt == 0:
		if i >= k:
			k = k
			n = i
		else:
			k = k - i
			n = n - i
	elif i > k:
		k = k
		n += 1
	else:
		k += 1
		n += 1
	print(n, k)


import sys

def main():
	input = sys.stdin.readline()
	(n, k, m, t) = [int(j) for j in input.split()]
	for i in range(t):
		input = sys.stdin.readline()
		(d, c) = [int(j) for j in input.split()]
		if d == 0:
			if c < k:
				n -= c
				k -= c
			else:
				n = c
		else:
			if c <= k:
				k += 1
			n += 1
		print(n, k)
main()


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, k, m, t) = value()
for i in range(t):
	(t, ind) = value()
	if t:
		n += 1
		if ind <= k:
			k += 1
	elif ind < k:
		k -= ind
		n -= ind
	else:
		n = ind
	print(n, k)


(n, k, m, t) = map(int, input().split())
l = [1] * n
l[k - 1] = 'doc'
for i in range(t):
	(op, idx) = map(int, input().split())
	if op == 0:
		if idx < k:
			while idx:
				l.pop(0)
				idx -= 1
		else:
			idx = len(l) - idx
			while idx:
				l.pop()
				idx -= 1
		y = len(l)
		print(y, end=' ')
		for x in range(y):
			if l[x] == 'doc':
				k = x + 1
				print(x + 1)
				break
	else:
		l.insert(idx - 1, 1)
		y = len(l)
		print(y, end=' ')
		for x in range(y):
			if l[x] == 'doc':
				k = x + 1
				print(x + 1)
				break


(n, k, m, t) = list(map(int, input().split(' ')))
l = n
r = 0
for _ in range(t):
	(check, pos) = list(map(int, input().split(' ')))
	if check == 1:
		l += 1
		if pos <= k - r:
			k += 1
		print(l - r, k - r)
	else:
		if pos < k - r:
			r += pos
		else:
			l = pos + r
		print(l - r, k - r)


(n, k, m, t) = map(int, input().split())
c = [1] * n
pos = k - 1
for _ in range(t):
	(l, r) = map(int, input().split())
	r -= 1
	if l == 0:
		if r < pos:
			del c[:r + 1]
			pos = pos - r - 1
		else:
			del c[r + 1:]
		print(len(c), pos + 1)
	else:
		c.insert(r, 1)
		if r <= pos:
			pos += 1
		print(len(c), pos + 1)


(n, k, m, t) = list(map(int, input().split()))
for tt in range(t):
	(op, i) = list(map(int, input().split()))
	if op == 1:
		if i <= k:
			k += 1
		n += 1
	elif op == 0:
		if i < k:
			k -= i
			n -= i
		else:
			n -= n - i
	print(n, k)


(n, k, m, t) = list(map(int, input().split()))
for _ in range(t):
	(c, i) = list(map(int, input().split()))
	if c == 1:
		n += 1
		if i <= k:
			k += 1
	if c == 0:
		if i < k:
			k -= i
			n -= i
		else:
			n = i
	print(n, k)


(n, k, m, t) = list(map(int, input().split()))
for i in range(t):
	q = list(map(int, input().split()))
	if q[0] == 0:
		ind = q[1]
		if k > ind:
			k -= ind
			n -= ind
		else:
			n -= n - ind
	else:
		ind = q[1]
		if k >= ind:
			k += 1
		n += 1
	print(n, k)


(n, k, m, T) = [int(i) for i in input().split()]
for t in range(T):
	(x, y) = [int(i) for i in input().split()]
	if x == 1:
		n += 1
		if y <= k:
			k += 1
	elif y >= k:
		n = y
	else:
		n -= y
		k -= y
	print(n, k)


(n, k, m, t) = map(int, input().split())
pos = k
l = n
for tt in range(t):
	(ty, val) = map(int, input().split())
	if ty == 0:
		if val < pos:
			pos = pos - val
			l = l - val
		else:
			l = val
	else:
		l += 1
		if val <= pos:
			pos += 1
	print(l, pos)


import sys
from math import log2
import bisect
import heapq
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
(n, k, m, t) = Ri()
for _ in range(t):
	(a, b) = Ri()
	if a == 0:
		if k <= b:
			n = b
		else:
			k -= b
			n -= b
	else:
		if n + 1 > m:
			continue
		if b <= k:
			k += 1
			n += 1
		else:
			n += 1
	print(n, k)


(n, k, m, t) = list(map(int, input().split()))
for req in range(t):
	(q, i) = list(map(int, input().split()))
	if q == 1:
		n += 1
		if i <= k:
			k += 1
	elif i >= k:
		n = i
	else:
		n -= i
		k -= i
	print(n, k)


(n, k, m, t) = map(int, input().split(' '))
for _ in range(t):
	(op, pos) = map(int, input().split(' '))
	if op == 1:
		if k >= pos:
			k += 1
		n += 1
	elif k > pos:
		n -= pos
		k -= pos
	else:
		n = pos
	print(n, k)


nkmt = input().split(' ')
(n, k, m, t) = (int(nkmt[0]), int(nkmt[1]), int(nkmt[2]), int(nkmt[3]))
end = n
for i in range(t):
	line = input().split(' ')
	if line[0] == '1':
		pos = int(line[1])
		if pos > k:
			end += 1
		else:
			k += 1
			end += 1
	else:
		pos = int(line[1])
		if pos < k:
			k -= pos
			end -= pos
		else:
			end = pos
	print(end, k)


arr = input()
(N, K, M, T) = [int(x) for x in arr.split(' ')]
uni = [0] * N
uni[K - 1] = 1
for i in range(T):
	arr = input()
	(move, pos) = [int(x) for x in arr.split(' ')]
	if move == 0:
		u1 = uni[:pos]
		u2 = uni[pos:]
		if 1 in u1:
			uni = u1
		else:
			uni = u2
			K -= len(u1)
		print(len(uni), K)
	else:
		p = pos - 1
		u1 = uni[:p]
		u2 = uni[p:]
		uni = u1 + [0] + u2
		if 1 in u2:
			K += 1
		print(len(uni), K)


data0 = input().split()
n = int(data0[0])
k = int(data0[1])
m = int(data0[2])
t = int(data0[3])
mult = []
for i in range(n):
	if i == k - 1:
		mult.append(1)
	else:
		mult.append(0)
for i in range(t):
	data1 = input().split()
	a = int(data1[0])
	b = int(data1[1])
	if a == 1:
		mult.insert(b - 1, 0)
	elif mult.index(1) < b:
		del mult[b:]
	else:
		del mult[:b]
	print(len(mult), mult.index(1) + 1)


(n, k, m, t) = map(int, input().split())
ls = [0 for i in range(n)]
ls[k - 1] = 1
for i in range(t):
	(a, b) = map(int, input().split())
	if a == 0:
		c = ls[0:b]
		d = ls[b:]
		if c.count(1) == 1:
			ls = c
		else:
			ls = d
	else:
		c = []
		flag = True
		for i in range(len(ls)):
			if i == b - 1:
				c.append(0)
				flag = False
			c.append(ls[i])
		if flag:
			c.append(0)
		ls = c
	print(len(ls), ls.index(1) + 1)


(n, k, m, t) = map(int, input().split())
l = 1
r = n
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == 0:
		if b > k:
			r = b
		elif b == k:
			k = b
			r = b
		else:
			k -= b
			r -= b
		print(r, k)
	else:
		if b > k:
			r = min(r + 1, m)
		elif k + 1 <= m:
			k += 1
			r += 1
		print(r, k)


(n, k, m, t) = map(int, input().split())
l = [0] * n
l[k - 1] = 1
for _ in range(t):
	(c, i) = map(int, input().split())
	if c == 0:
		(a, b) = (l[:i], l[i:])
		if 1 in a:
			l = a
		else:
			l = b
	else:
		l.insert(i - 1, 0)
	print(len(l), l.index(1) + 1)


(n, k, m, t) = map(int, input().split())
for i in range(0, t):
	(t1, t2) = map(int, input().split())
	if t1 == 1:
		if t2 <= k:
			k += 1
		n += 1
	elif t2 < k:
		n -= t2
		k -= t2
	else:
		n -= n - t2
	print(n, k)


(lengte, dokter, _, t) = map(int, input().split())
lijst = [part.split() for part in [input() for _ in range(t)]]
for i in range(t):
	a = lijst[i]
	x = int(a[0])
	if x == 1:
		b = int(a[1])
		if b < dokter + 1:
			dokter += 1
		lengte += 1
	else:
		b = int(a[1])
		if b < dokter:
			dokter -= b
			lengte -= b
		else:
			lengte -= lengte - b
	print(lengte, dokter)


import collections
import itertools
from functools import reduce
mod = 10 ** 9 + 7

def permutationbysum():
	for _ in range(int(input())):
		(num, l, r, achieve) = map(int, input().split())
		k = r - l + 1
		if k * (k + 1) // 2 <= achieve <= k * (num * 2 + 1 - k) // 2:
			outpos = r % num
			inpos = l - 1
			ans = [0] * num
			for i in range(num, 0, -1):
				if achieve - i > 0 or (achieve - i == 0 and inpos == r - 1):
					achieve -= i
					ans[inpos] = i
					inpos += 1
				else:
					ans[outpos] = i
					outpos += 1
					outpos %= num
			print(*ans)
		else:
			print(-1)

def peaks():
	for _ in range(int(input())):
		(num, peak) = map(int, input().split())
		pos = 1
		rpos = num
		ans = []
		now = 0
		if num == 1:
			if not peak:
				print(1)
			else:
				print(-1)
			continue
		if num == 2:
			if peak:
				print(-1)
			else:
				print(1, 2)
			continue
		added = 0
		while rpos + 1 != pos:
			if not peak:
				while pos <= rpos:
					ans.append(pos)
					pos += 1
				break
			if not now:
				ans.append(pos)
				pos += 1
			else:
				ans.append(rpos)
				rpos -= 1
				if num - added != 1:
					peak -= 1
			added += 1
			now = 1 - now
		if peak:
			print(-1)
			continue
		print(*ans)
import sys
input = sys.stdin.readline

def addone():
	for _ in range(int(input())):
		(num, changes) = input().split()
		l = collections.deque(sorted([int(i) for i in num]))
		perm = collections.deque()
		changes = int(changes)
		cd = 0
		ans = len(num)
		while True:
			nextnum = l.pop()
			while perm and perm[-1] == nextnum:
				l.append(perm.pop())
			c = 10 - nextnum - cd
			changes -= c
			cd += c
			if changes >= 0:
				if not c:
					perm.appendleft(1 - cd)
					l.appendleft(-cd)
				else:
					l.appendleft(1 - cd)
					l.appendleft(-cd)
				ans += 1
			else:
				break
		print(ans % 1000000007)
import math

def andsequences():

	def mapping(num):
		nonlocal mnum
		nonlocal c
		num = int(num)
		if num < mnum:
			mnum = num
			c = 1
		elif num == mnum:
			c += 1
		return num
	mod = 1000000007
	for _ in range(int(input())):
		mnum = float('inf')
		c = 0
		num = int(input())
		l = list(map(mapping, input().split()))
		for i in l:
			if mnum & i != mnum:
				print(0)
				break
		else:
			if c == 1:
				print(0)
			else:
				print(math.factorial(num - 2) * (c - 1) * c % mod)

def numberdigit():
	n = 10 ** 5 * 2
	l = [0] * 11
	mod = 10 ** 9 + 7
	l[0] = l[1] = l[2] = l[3] = l[4] = l[5] = l[6] = l[7] = l[8] = 2
	l[9] = 3
	l[10] = 4
	for i in range(11, n):
		l.append((l[i - 10] + l[i - 9]) % mod)
	for _ in range(int(input())):
		(num, c) = input().split()
		c = int(c)
		ans = 0
		for i in num:
			i = int(i)
			if 10 - i > c:
				ans += 1
			else:
				ans += l[c - (10 - i)]
		print(ans % mod)

def mushroom():
	(people, t1, t2, percent) = map(int, input().split())
	l = []
	percent = 1 - percent * 0.01
	for i in range(1, people + 1):
		(s, s1) = map(int, input().split())
		l.append([i, max(s * t1 * percent + s1 * t2, s1 * t1 * percent + s * t2)])
	l.sort(key=lambda x: x[1], reverse=True)
	for i in l:
		i[1] = '{:.2f}'.format(i[1])
		print(*i)

def escape():
	prins = int(input())
	dra = int(input())
	start = int(input())
	pack = int(input())
	c = int(input())
	speeddiff = dra - prins
	if speeddiff <= 0:
		return 0
	pd = start * prins
	ans = 0
	while pd < c:
		hs = pd / speeddiff
		pd += prins * hs
		if pd >= c:
			break
		time = pd / dra
		time += pack
		pd += prins * time
		ans += 1
	return ans

def perm():

	def high(n, k):
		return k * (2 * n - k + 1) // 2

	def low(k):
		return k * (k + 1) // 2
	for _ in range(int(input())):
		(num, lef, rig, s) = map(int, input().split())
		k = rig - lef + 1
		(rig, lef) = (rig - 1, lef - 1)
		if not high(num, k) >= s >= low(k):
			print(-1)
			continue
		l = [0] * num
		lp = lef
		rp = lef - 1
		for i in range(num, 0, -1):
			if high(i, k) >= s and s - i >= low(k - 1) and k:
				l[lp] = i
				lp += 1
				s -= i
				k -= 1
			else:
				l[rp] = i
				rp -= 1
		if k:
			print(-1)
		else:
			print(*l)

def newcom():
	for _ in range(int(input())):
		(days, price) = map(int, input().split())
		dl = input().split()
		worth = input().split()
		worth.append(0)
		ans = float('inf')
		req = 0
		left = 0
		for i in range(days):
			a = int(dl[i])
			w = int(worth[i])
			ans = min(ans, req + max(0, price - left + a - 1) // a)
			ns = max(0, w - left + a - 1) // a
			req += ns + 1
			left += a * ns - w
		print(ans)

def perfectsq():
	for _ in range(int(input())):
		n = input()
		for i in input().split():
			sq = math.sqrt(int(i))
			if sq != int(sq):
				print('YES')
				break
		else:
			print('NO')

def and0big():
	for _ in range(int(input())):
		(l, k) = map(int, input().split())
		print(l ** k % mod)
import math

def mod1p():
	n = int(input())
	ans = dict()
	p = 1
	for i in range(1, n):
		if math.gcd(i, n) == 1:
			ans[str(i)] = True
			p = p * i % n
	if p == 1:
		print(len(ans))
		print(' '.join(ans.keys()))
	else:
		ans.pop(str(p))
		print(len(ans))
		print(' '.join(ans.keys()))

def shorttask():
	num = 10000100
	l = [-1] * (num + 2)
	s = [-1] * (num + 2)
	l[1] = 1
	for i in range(2, int(math.sqrt(num + 1)) + 2):
		if l[i] == -1:
			l[i] = i
			for x in range(i * i, num + 1, i):
				if l[x] == -1:
					l[x] = i
	s[1] = 1
	for i in range(2, num + 1):
		if l[i] == -1:
			l[i] = i
			s[i] = i + 1
		else:
			i1 = i
			s[i] = 1
			while i1 % l[i] == 0:
				i1 //= l[i]
				s[i] = s[i] * l[i] + 1
			s[i] *= s[i1]
	ans = [-1] * (num + 1)
	for i in range(num, 0, -1):
		if s[i] < num:
			ans[s[i]] = i
	for _ in range(int(input())):
		print(ans[int(input())])

def review():
	for _ in range(int(input())):
		n = int(input())
		ans = 0
		for i in input().split():
			i = int(i)
			if i == 1 or i == 3:
				ans += 1
		print(ans)

def GCDleng():
	po10 = [0] * 11
	po10[1] = 1
	for i in range(2, 11):
		po10[i] = po10[i - 1] * 10
	for _ in range(int(input())):
		(n, n1, res) = map(int, input().split())
		print(po10[n], po10[n1] + po10[res])

def anothercarddeck():
	(n, q) = map(int, input().split())
	l = input().split()
	d = {l[i]: i for i in range(n - 1, -1, -1)}
	ans = []
	for i in input().split():
		now = d[i]
		ans.append(now + 1)
		for key in d:
			if d[key] < now:
				d[key] += 1
		d[i] = 0
	print(*ans)

def mincoststring():
	(n, letters) = map(int, input().split())
	l = [chr(i + 97) for i in range(letters)]
	ans = []
	real = letters - 1
	if not n:
		print(*ans, sep='')
		return
	if n == 1:
		print(*ans, sep='', end='')
		print(l[1 % (real + 1)])
		return
	while n:
		for i in range(len(l)):
			for i1 in range(i, len(l)):
				if i1 != real:
					ans.append(l[i1])
					ans.append(l[i])
					n -= 2
				else:
					ans.append(l[i1])
					n -= 1
				if not n:
					print(*ans, sep='')
					return
				if n == 1:
					print(*ans, sep='', end='')
					print(l[(i1 + 1) % (real + 1)])
					return
	print(*ans)

def mincost2():
	(n, letters) = map(int, input().split())
	l = [chr(i + 97) for i in range(letters)]
	comb = []
	if letters == 1 or n == 1:
		print('a' * n)
		return
	for i in range(letters):
		for i1 in range(i, letters):
			comb.append(l[i1] + l[i])
	lc = len(comb)
	while True:
		for i in range(lc):
			if ord(comb[i][0]) - 97 == letters - 1:
				n -= 1
				print(comb[i][0], end='')
			else:
				n -= 2
				print(comb[i], end='')
			if n == 1:
				pos = ord(comb[i][0]) - 97 + 1
				print(l[pos % letters])
				return
			if not n:
				return

def Tittat():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		l = list(map(int, input().split()))
		for i in range(n):
			if not k:
				break
			while k and l[i]:
				l[i] -= 1
				l[-1] += 1
				k -= 1
		print(*l)

def xorq2():
	for _ in range(int(input())):
		n = int(input())
		s = 0
		num = -1
		nc = 0
		c = 0
		for i in input().split():
			i = int(i)
			s ^= i
			c += 1
			if num == -1 and s == i:
				num = s
				s = 0
				nc += c
				c = 0
			if num != -1 and (s == num or not s):
				s = 0
				nc += c
				c = 0
		print(['NO', 'YES'][nc == n])

def xorq2re():
	n = int(input())
	s = input().split()
	xor = 0
	for i in range(n):
		s[i] = int(s[i])
		xor ^= s[i]
	if not xor:
		print('YES')
	else:
		new = 0
		ans = 0
		for i in s:
			new ^= i
			if new == xor:
				new = 0
				ans += 1
		print(['NO', 'YES'][ans > 1])
import sys
sys.setrecursionlimit(2300)

def q3partition():

	def partition():
		if tol % 2:
			return 0
		up = tol
		rec = [[False] * (up + 2) for _ in range(n + 1)]
		rec[0][0] = True
		for i in range(1, n + 1):
			v = l[i - 1]
			for j in range(up + 1):
				if rec[i - 1][j]:
					if v + j <= up:
						rec[i][j + v] = True
					rec[i][j] = True
		return rec[n][tol // 2]

	def ints(x):
		nonlocal tol
		nonlocal gcf
		x = int(x)
		tol += x
		gcf = math.gcd(gcf, x) if gcf != float('inf') else x
		return x
	n = int(input())
	tol = 0
	gcf = float('inf')
	l = list(map(ints, input().split()))
	if partition():
		pos = 1
		for i in l:
			if i // gcf % 2:
				print(1)
				print(pos)
				return
			pos += 1
	else:
		print(0)

def permu(n, r):
	return math.factorial(n) // math.factorial(n - r)

def comb(n, r):
	return math.factorial(n) // math.factorial(r) * math.factorial(n - r)

def calc():
	n = int(input())
	ans = permu(n, n)
	for i in range(1, n + 1):
		ans -= comb(n, i)
	print(ans)

def order():
	for _ in range(int(input())):
		n = int(input())
		odd = []
		even = []
		for i in input().split():
			i = int(i)
			if i % 2:
				odd.append(i)
			else:
				even.append(i)
		print(*odd + even)

def TMTdoc():
	n = int(input())
	l = input().rstrip()
	tts = 0
	tms = 0
	for i in l:
		if i == 'T':
			tts += 1
		else:
			tms += 1
	if tms * 2 == tts:
		nowts = 0
		nowms = 0
		for i in l:
			if i == 'T':
				nowts += 1
			else:
				nowms += 1
				if nowts >= nowms and tms - nowms + 1 <= tts - nowts:
					continue
				return 'NO'
	else:
		return 'NO'
	return 'YES'

def relayrace():

	def solve(n):
		if n:
			s = -1
		else:
			s = 1
		nowmax = -float('inf')
		nowmin = -nowmax
		ans = 0
		for (i, v) in sorted(l, key=lambda x: (x[1], s * int(x[0])), reverse=True):
			i = int(i)
			if i > nowmax:
				nowmax = i
			if i < nowmin:
				nowmin = i
			ans += v * (nowmax - nowmin)
		return ans
	n = int(input())
	l = -1
	ans = 0
	for i in sorted(input().split(), key=lambda x: int(x)):
		if l == -1:
			l = int(i)
		else:
			ans += int(i) - l
	return ans

def relayraces():
	n = int(input())
	l = sorted(map(int, input().split()))
	minv = float('INF')
	minpos = 0
	for i in range(len(l)):
		if i > 0 and 0 <= l[i] - l[i - 1] <= minv:
			minv = l[i] - l[i - 1]
			minpos = i
		if i < n - 1 and l[i + 1] - l[i] <= minv:
			minv = l[i + 1] - l[i]
			minpos = i
	lpos = minpos - 1
	rpos = minpos + 1
	ans = 0
	while lpos >= 0 and rpos < n:
		diffl = -(l[lpos] - l[minpos])
		diffr = l[rpos] - l[minpos]
		if diffl < diffr:
			minpos = lpos
			lpos -= 1
			ans += diffl
		else:
			minpos = rpos
			rpos += 1
			ans += diffr
	if lpos < 0:
		m = l[0]
		for i in range(rpos, n):
			ans += l[i] - m
	else:
		h = l[-1]
		for i in range(minpos, -1, -1):
			ans += h - l[i]
	return ans

def relayracess():

	def recur(l, r):
		if l == r:
			return 0
		if d[l, r] != -1:
			return d[l, r]
		ans = nums[r] - nums[l] + min(recur(l + 1, r), recur(l, r - 1))
		d[l, r] = ans
		return ans
	d = collections.defaultdict(lambda : -1)
	n = int(input())
	nums = sorted(map(int, input().split()))
	return recur(0, n - 1)

def relayracesss():
	n = int(input())
	l = sorted(map(int, input().split()))
	dp = [[0] * n for _ in range(n)]
	for i in range(n - 2, -1, -1):
		for i1 in range(i + 1, n):
			dp[i][i1] = l[i1] - l[i] + min(dp[i + 1][i1], dp[i][i1 - 1])
	return dp[0][n - 1]

def relayracessss():
	n = int(input())
	l = sorted(map(int, input().split()))
	dp = [0] * n
	for le in range(n - 2, -1, -1):
		for ri in range(le + 1, n):
			dp[ri] = l[ri] - l[le] + min(dp[ri], dp[ri - 1])
	return dp[-1]

def binli():
	n = int(input())
	n2 = n * 2
	s = input().rstrip()
	s1 = input().rstrip()
	s2 = input().rstrip()
	posl = [0, 0, 0]
	ans = ''
	while max(posl) < n2:
		l = [[], []]
		l[int(s[posl[0]])].append(0)
		l[int(s1[posl[1]])].append(1)
		l[int(s2[posl[2]])].append(2)
		if len(l[0]) >= 2:
			for i in l[0]:
				posl[i] += 1
			ans += '0'
		else:
			for i in l[1]:
				posl[i] += 1
			ans += '1'
	if posl[0] == n2:
		if posl[1] >= posl[2]:
			ans += s1[posl[1]:]
		else:
			ans += s2[posl[2]:]
	elif posl[1] == n2:
		if posl[0] >= posl[2]:
			ans += s[posl[0]:]
		else:
			ans += s2[posl[2]:]
	elif posl[0] >= posl[1]:
		ans += s[posl[0]:]
	else:
		ans += s1[posl[1]:]
	print(ans)

def almostsort():
	(n, k) = map(int, input().split())
	ul = 2 ** (n - 1)
	if k > ul:
		return [-1]
	permen = []
	bi = bin(k - 1)[2:]
	if bi == '0':
		return range(1, n + 1)
	pos = n - len(bi)
	ans = list(range(1, pos))
	for i in bi:
		permen.append(pos)
		if not int(i):
			ans += permen[::-1]
			permen = []
		pos += 1
	permen.append(n)
	ans += permen[::-1]
	return ans

def q1_2050():
	for i in range(int(input())):
		s = int(input())
		if s % 2050:
			print(-1)
		else:
			ab = 2050
			while ab <= s:
				ab *= 10
			ab //= 10
			c = 0
			while s and s != 1:
				c += s // ab
				s = s % ab
				while s != 1 and s and (s < ab):
					ab //= 10
			print(c)

def q2jog():
	(n, m) = map(int, input().split())
	sortbyval = []
	rowsv = [collections.defaultdict(int) for _ in range(n)]
	for row in range(n):
		for i in input().split():
			i = int(i)
			sortbyval.append([i, row])
			rowsv[row][i] += 1
	sortbyval.sort(key=lambda x: x[0])
	larl = []
	for i in range(0, n * m, m):
		larl.append(sortbyval[i:i + m])
	ans = [[0] * m for _ in range(n)]
	person = 0
	for i in larl:
		for (v, pos) in i:
			ans[pos][person] = v
			rowsv[pos][v] -= 1
			person += 1
			if person == m:
				break
		else:
			continue
		break
	for r in range(n):
		for c in range(m):
			if not ans[r][c]:
				for key in list(rowsv[r].keys()):
					if not rowsv[r][key]:
						rowsv[r].pop(key)
						continue
					rowsv[r][key] -= 1
					ans[r][c] = key
					break
	for i in ans:
		print(*i)

def q3fillomino(n, inp):

	def gorow():
		nonlocal nowp
		nonlocal col
		nonlocal totake
		t = 0
		if nowp and col < n and totake and (not l[col][nowp - 1]):
			for back in range(nowp, -1, -1):
				if l[col][back]:
					nowp += 1
					col += 1
					return t
				if not totake:
					return t
				l[col][back] = i
				totake -= 1
				nowp -= 1
				t = 1
			nowp += 1
			col += 1
		return t
	l = [[0] * i for i in range(1, n + 1)]
	p = 0
	for i in inp:
		totake = int(i)
		nowp = p
		col = p
		while col < n:
			if not totake:
				break
			for _ in range(n - p):
				if not gorow():
					break
			if not totake or col == n or nowp == n:
				break
			l[col][nowp] = i
			totake -= 1
			col += 1
		p += 1
	for i in l:
		print(*i)

def q3fillominoclear(n, inp):
	l = [[0] * i for i in range(1, n + 1)]
	p = 0
	for i in inp:
		take = int(i) - 1
		l[p][p] = i
		(x, y) = (p, p)
		while take:
			if y and (not l[x][y - 1]):
				y -= 1
			else:
				x += 1
			l[x][y] = i
			take -= 1
		p += 1
	for i in l:
		print(*i)

def q4explor():

	def gen(r, c):
		res = float('inf')
		if r:
			res = min(res, his[r - 1][c] + 2 * colstep[r - 1][c])
		if r < rows - 1:
			res = min(res, his[r + 1][c] + 2 * colstep[r][c])
		if c:
			res = min(res, his[r][c - 1] + 2 * rowstep[r][c - 1])
		if c < cols - 1:
			res = min(res, his[r][c + 1] + 2 * rowstep[r][c])
		return res
	(rows, cols, k) = map(int, input().split())
	if k % 2:
		for i in range(rows):
			print(*[-1] * cols)
		return
	rowstep = [list(map(int, input().split())) for _ in range(rows)]
	colstep = [list(map(int, input().split())) for _ in range(rows - 1)]
	his = [[0] * cols for _ in range(rows)]
	for _ in range(k // 2):
		temp = [[gen(r, c) for c in range(cols)] for r in range(rows)]
		his = temp
	for i in his:
		print(*i)

def cvacations():

	def de(v):
		nonlocal last
		if v == 2:
			last = 2
		elif v == 1:
			last = 1
	n = int(input())
	ans = 0
	last = 0
	l = input().split()
	for i1 in range(n):
		i = int(l[i1])
		if not i:
			last = 0
			ans += 1
			continue
		if i == 1:
			if last != 2:
				last = 2
				continue
			ans += 1
			last = 0
		elif i == 2:
			if last != 1:
				last = 1
				continue
			ans += 1
			last = 0
		elif not last:
			if i1 < n - 1:
				de(int(l[i1 + 1]))
				if int(l[i1 + 1]) == 3:
					for pos in range(i1 + 2, n):
						if l[pos] != 3:
							r = l[pos]
							break
					else:
						last = 1
						continue
					de(r)
			else:
				break
		elif last == 1:
			last = 2
		elif last == 2:
			last = 1
	return ans

def brackets():
	s = input().rstrip()
	(lpos, rpos) = (0, len(s) - 1)
	ans = []
	while lpos + 1 <= rpos:
		if s[lpos] == '(':
			if s[rpos] == ')':
				ans.append(lpos + 1)
				ans.append(rpos + 1)
				lpos += 1
				rpos -= 1
			else:
				rpos -= 1
		else:
			lpos += 1
	if ans:
		print(1)
		print(len(ans))
		print(*sorted(ans))
	else:
		print(0)

def In():
	return map(int, input().split())

def complibook():
	(n, q) = In()
	nums = list(In())
	for _ in range(q):
		(l, r, x) = In()
		num = nums[x - 1]
		les = 0
		for i in range(l - 1, r):
			if nums[i] < num:
				les += 1
		print(['No', 'Yes'][les + l - 1 == x - 1])

def bstr():
	for _ in range(int(input())):
		(n, k) = In()
		now = 1
		times = 2
		while k > now:
			k -= now
			now += 1
			times += 1
		fir = n - times
		sec = n - k
		for i in range(n):
			if i == fir or i == sec:
				print('b', end='')
			else:
				print('a', end='')
		print()

def avgsuper():
	(n, k, oper) = In()
	l = sorted(In(), reverse=True)
	nowavg = sum(l) / n
	(addpos, addnum) = (0, 0)
	for i in range(oper):
		if n == 1 and addpos != 0:
			break
		new = (nowavg * n - l[n - 1]) / max(n - 1, 1)
		if 1 / n > new - nowavg and addpos < n:
			addnum += 1
			if addnum >= k:
				addpos += 1
				addnum = 0
			nowavg += 1 / n
		else:
			nowavg = new
			n -= 1
	print(nowavg)

def avgsuper2():
	(n, k, oper) = In()
	l = sorted(In(), reverse=True)
	prefix = [0] * (n + 1)
	for i in range(1, n + 1):
		prefix[i] = l[i - 1] + prefix[i - 1]
	prefix.pop(0)
	ans = 0
	for i in range(n - 1, max(-1, n - oper - 2), -1):
		ans = max(ans, (prefix[i] + min(k * (i + 1), oper - (n - i - 1))) / (i + 1))
	return ans

def tanna():
	(n, k, A, B) = (int(input()), int(input()), int(input()), int(input()))
	if k == 1:
		return (n - 1) * A
	x = n
	ans = 0
	while x != 1:
		if x < k:
			return ans + A * (x - 1)
		if not x % k:
			nexts = x // k
			ans += min(B, A * (x - nexts))
			x = nexts
		else:
			new = x % k
			ans += new * A
			x = x - new
	return ans

def segsqu():
	square = 1
	num = int(input())
	while num > square * square:
		square += 1
	cols = square
	rows = math.ceil(num / cols)
	print(cols + rows)

def ParallelUniverses():
	(n, k, m, t) = In()
	for _ in range(t):
		(sta, pos) = In()
		if sta:
			n += 1
			if pos - 1 < k:
				k += 1
		elif pos < k:
			k -= pos
			n -= pos
		else:
			n = pos
		print(n, k)
ParallelUniverses()


(n, k, m, t) = input().split()
(n, k, m, t) = (int(n), int(k), int(m), int(t))
for i in range(t):
	(what, pos) = input().split()
	(what, pos) = (int(what), int(pos))
	if what == 0:
		if pos >= k:
			n = pos
		else:
			n = n - pos
			k = k - pos
	else:
		n += 1
		if pos <= k:
			k += 1
	print(n, end=' ')
	print(k)