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 Segtree: def __init__(self, A, ide_ele, initialize = True, segf = max): self.N = len(A) self.N0 = 2**(self.N-1).bit_length() self.ide_ele = ide_ele self.segf = segf if initialize: self.data = [ide_ele]*self.N0 + A + [ide_ele]*(self.N0 - self.N) for i in range(self.N0-1, 0, -1): self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) else: self.data = [ide_ele]*(2*self.N0) def update(self, k, x): k += self.N0 self.data[k] = x while k > 0 : k = k >> 1 self.data[k] = self.segf(self.data[2*k], self.data[2*k+1]) def query(self, l, r): L, R = l+self.N0, r+self.N0 s = self.ide_ele while L < R: if L & 1: s = self.segf(s, self.data[L]) L += 1 if R & 1: R -= 1 s = self.segf(s, self.data[R]) L >>= 1 R >>= 1 return s 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=Segtree(A, [[0,0],0], segf=func) 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.query(0,i+1) # print("++++",i,*vn,tn*180/PI,"++++") print(*vn) # for i in range(N): # vn,thn=seg.query(i,i+1) # print(vn,thn*180/PI) main()