import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) def mat_mul(A, B): res = [[0] * len(B[0]) for _ in range(len(A))] for i in range(len(A)): for k in range(len(A[0])): for j in range(len(B[0])): res[i][j] += A[i][k] * B[k][j] return res N, px, py = map(int, input().split()) query = tuple(tuple(map(int,input().split())) for _ in range(N)) rot = [[0, 1, 0], [-1, 0, 0], [0, 0, 1]] move = lambda x, y: [[1, 0, x], [0, 1, y], [0, 0, 1]] A = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] b = [[px],[py],[1]] ans = [] for flag, *arg in query[::-1]: if flag == 1: A = mat_mul(A, move(arg[0], 0)) elif flag == 2: A = mat_mul(A, move(0, arg[0])) else: A = mat_mul(A, rot) X, Y, _ = mat_mul(A, b) ans.append((*X, *Y)) ans.reverse() for x, y in ans: print(x, y)