from math import radians, sin, cos n,q=map(int,input().split()) theta=[0]*n length=[1]*n for _ in range(q): query=list(map(int,input().split())) if query[0]==0: _,i,x=query theta[i-1]=x elif query[0]==1: _,i,x=query length[i-1]=x else: _,i=query x=y=0 the=0 for j in range(i): the+=theta[j] the%=360 x+=length[j]*cos(radians(the)) y+=length[j]*sin(radians(the)) print('{:.9f}'.format(x),'{:.9f}'.format(y))