N, px, py = map(int, input().split()) C = [] for i in range(N): C.append(list(map(int, input().split()))) C.reverse() n = 0 def Mat(x, y, f): if f == 1: return [[0, 1, 0], [-1, 0, 0], [0, 0, 1]] return [[1, 0, x], [0, 1, y], [0, 0, 1]] def Matprod(A, B): N = len(A) C = [[0] * len(B[0]) for i in range(N)] for i in range(N): for j in range(len(B[0])): for k in range(N): C[i][j] += A[i][k] * B[k][j] return C ans = [] now = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] for c in C: if c[0] == 3: now = Matprod(now, Mat(-1, -1, 1)) elif c[0] == 1: now = Matprod(now, Mat(c[1], 0, 0)) else: now = Matprod(now, Mat(0, c[1], 0)) x, y, _ = Matprod(now, [[px], [py], [1]]) ans.append((x, y)) ans.reverse() for x, y in ans: print(x[0], y[0])