N, Px, Py = map(int, input().split()) C = [tuple(map(int, input().split())) for _ in range(N)] res = [] x, y = Px, Py orient = ((1, 0), (0, 1), (-1, 0), (0, -1)) i = 0 for c in reversed(C): if c[0] == 1: x += orient[i][0] * c[1] y += orient[i][1] * c[1] elif c[0] == 2: x += orient[(i + 1) % 4][0] * c[1] y += orient[(i + 1) % 4][1] * c[1] else: x, y = y, -x i = (i - 1) % 4 res.append((x, y)) for xy in reversed(res): print(*xy)