def rotate_point(r, x, y): if r == 0: return x, y elif r == 1: return y, -x elif r == 2: return -x, -y else: # r == 3 return -y, x n, Px, Py = map(int, input().split()) commands = [] for _ in range(n): parts = input().split() if parts[0] == '1': dx = int(parts[1]) commands.append(('1', dx)) elif parts[0] == '2': dy = int(parts[1]) commands.append(('2', dy)) else: commands.append(('3',)) # Initialize transformations array transformations = [(0, 0, 0)] * (n + 1) transformations[n] = (0, 0, 0) for i in range(n - 1, -1, -1): cmd = commands[i] r_t, dx_t, dy_t = 0, 0, 0 if cmd[0] == '1': dx_t = cmd[1] elif cmd[0] == '2': dy_t = cmd[1] elif cmd[0] == '3': r_t = 1 r_next, dx_next, dy_next = transformations[i + 1] composed_r = (r_t + r_next) % 4 rotated_dx, rotated_dy = rotate_point(r_next, dx_t, dy_t) new_dx = rotated_dx + dx_next new_dy = rotated_dy + dy_next transformations[i] = (composed_r, new_dx, new_dy) for k in range(n): r, dx, dy = transformations[k] px_rot, py_rot = rotate_point(r, Px, Py) ax = px_rot + dx ay = py_rot + dy print(ax, ay)