import math N,Q = map(int,input().split()) kyoku = [1 for _ in range(N)] #theta, R, 0index now = [[0,ii+1] for ii in range(N)] B = [0 for _ in range(N)] kakudo = [0 for _ in range(N)] Flag = True for _ in range(Q): query = list(map(int,input().split())) #ID,i,x ID = query[0] i = query[1] - 1 #0index if ID == 0: #角度 B[i] += query[2]; Flag = False elif ID == 1: #長さ kyoku[i] = query[2]; Flag = False else: #prevB = [0 for _ in range(N)] #imos法のリセット #B, preB = prevB, B #print(B,kakudo) if Flag: #直前に更新したばかりであればそのままでよい。 print(*now[i]) continue for j in range(N): if j == 0: kakudo[j] += B[j] Theta = math.radians(B[0]) else: B[j] += B[j-1] #print(kakudo,B) kakudo[j] += B[j] Theta = math.radians(kakudo[j]) R = kyoku[j] #print(Theta,B[j],R) if j == 0: now[j][0] = R*math.cos(Theta) now[j][1] = R*math.sin(Theta) else: now[j][0] = now[j-1][0] + R*math.cos(Theta) now[j][1] = now[j-1][1] + R*math.sin(Theta) #print(now) print(*now[i]) Flag = True #print(kakudo) kakudo = B B = [0 for _ in range(N)] #print(kakudo)