import numpy as np N,P_x,P_y=list(map(int,input().split())) R=[None]*N dot=[None]*N for i in range(N): ope=list(map(int,input().split())) if ope[0]==1: R[i]=np.array([[1,0,ope[1]],[0,1,0],[0,0,1]]) elif ope[0]==2: R[i]=np.array([[1,0,0],[0,1,ope[1]],[0,0,1]]) else: R[i]=np.array([[0,1,0],[-1,0,0],[0,0,1]]) ope=np.eye(3) for i in range(N): ope=np.dot(ope,R[N-1-i]) dot[N-1-i]=np.dot(ope,np.array([P_x,P_y,1]).T) for i in range(N): print(str(int(dot[i].T[0])) + " " + str(int(dot[i].T[1])))