# coding: utf-8 def mul(a,b): tmp=[[0,0,0],[0,0,0],[0,0,0]] for i in range(3): for j in range(3): for k in range(3): tmp[i][j]+=a[i][k]*b[k][j] return tmp def mul_v(a,b): tmp=[0,0,0] for i in range(3): for j in range(3): tmp[i]+=a[i][j]*b[j] return tmp n,px,py=map(int,input().split()) d=[] for i in range(n): s=input() if s=='3': d.append([[0,1,0],[-1,0,0],[0,0,1]]) elif s[0]=='1': d.append([[1,0,int(s.split()[1])],[0,1,0],[0,0,1]]) else: d.append([[1,0,0],[0,1,int(s.split()[1])],[0,0,1]]) for i in range(len(d)-1): i=len(d)-1-i d[i-1]=mul(d[i],d[i-1]) for i in range(n): print(*mul_v(d[i],[px,py,1])[:2])