import numpy as np N, Px, Py = map(int, input().split()) matrices = [] matrix = np.diag([1] * 3) C = [tuple(map(int, input().split())) for _ in range(N)] for cmd in reversed(C): if cmd[0] == 1: matrix = np.dot([[1, 0, 0], [0, 1, 0], [cmd[1], 0, 1]], matrix) elif cmd[0] == 2: matrix = np.dot([[1, 0, 0], [0, 1, 0], [0, cmd[1], 1]], matrix) elif cmd[0] == 3: matrix = np.dot([[0, -1, 0], [1, 0, 0], [0, 0, 1]], matrix) matrices.append(matrix) for matrix in reversed(matrices): x, y = np.dot([Px, Py, 1], matrix)[:2] print(x, y)