import sys input=sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): from math import sin,cos,pi PI=pi class SegmentTree: def __init__(self, a, func=max, one=-10 ** 18): self.logn = (len(a) - 1).bit_length() self.n = 1 << self.logn self.func = func self.one = one self.b = [self.one] * (2 * self.n - 1) for i, j in enumerate(a): self.b[i + self.n - 1] = j for i in reversed(range(self.n - 1)): self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) def get_item(self, i): return self.b[i + self.n - 1] def update(self, index, x): i = index + self.n - 1 self.b[i] = x while i != 0: i = (i - 1) // 2 self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) def update_func(self, index, x): i = index + self.n - 1 self.b[i] = self.func(self.b[i], x) while i != 0: i = (i - 1) // 2 self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) def get_segment(self, l, r): l += self.n r += self.n s = self.one t = self.one while l < r: if l & 1: s = self.func(s, self.b[l - 1]) l += 1 if r & 1: r -= 1 t = self.func(self.b[r - 1], t) l >>= 1 r >>= 1 return self.func(s, t) def ch(X): return (X*PI)/180 def func(a,b): [x1,y1],t1 = a [x2,y2],t2 = b x=x1 + x2*cos(t1) - y2*sin(t1) y=y1 + x2*sin(t1) + y2*cos(t1) th=(t1+t2) # print("a:",a," b:",b) # print([[x,y],th*180/PI]) return [[x,y],th] N,Q=MI() A=[[[1,0],0]for _ in range(N)] seg=SegmentTree(A, func, [[0,0],0]) ds=[1]*N ths=[0]*N for _ in range(Q): q=LI() if q[0]==0: i=q[1]-1 th=ch(q[2]) ths[i]=th dn=ds[i] v=[dn*cos(th),dn*sin(th)] seg.update(i,[v,th]) elif q[0]==1: i=q[1]-1 d=q[2] ds[i]=d thn=ths[i] v=[d*cos(thn), d*sin(thn)] seg.update(i,[v,thn]) else: #print("++++++++++++++") i=q[1]-1 vn,tn=seg.get_segment(0,i+1) print(*vn) # for i in range(N): # vn,thn=seg.query(i,i+1) # print(vn,thn*180/PI) main()