import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N,px,py = map(int,readline().split()) CMD = readlines() answer = [] mat = np.eye(3,dtype=np.int64) v = np.array([px,py,1],np.int64).reshape(-1,1) for cmd in CMD[::-1]: t,*data = map(int,cmd.split()) if t == 3: mat[:2,:2] = np.dot(mat[:2,:2], np.array([[0,1],[-1,0]],np.int64)) elif t == 1: d = data[0] mat[:,2] += d * mat[:,0] elif t == 2: d = data[0] mat[:,2] += d * mat[:,1] x,y = np.dot(mat,v).ravel()[:2] answer.append('{} {}'.format(x,y)) print('\n'.join(answer[::-1]))