from math import cos, sin, radians import sys input = lambda: sys.stdin.readline().rstrip() # 行列a*行列b def matprod(a, b): n = len(a) l = len(b) m = len(b[0]) return [[sum(a[i][k]*b[k][j]for k in range(l)) for j in range(m)]for i in range(n)] # 行列a^n def matpow(a, n): ans = [[i == j for j in range(len(a[0]))]for i in range(len(a))] d = a[:][:] while n != 0: if n & 1: ans = matprod(d, ans) d = matprod(d, d) n >>= 1 return ans # SegmentTree class SegmentTree: def segp(self):print(self.seg) def __init__(self, n, p, unit, f, g, h): num = 2**((n-1).bit_length()) seg = [unit]*(num*2) self.lazy = [None]*(num*2) for i in range(n): seg[num+i] = p[i] for i in range(num-1, 0, -1): seg[i] = f(seg[i << 1], seg[(i << 1)+1]) self.num = num self.seg = seg self.unit = unit self.flag = False self.f = f self.g = g self.h = h def gindex(self, l, r): l += self.num r += self.num lm = (l//(l & -l)) >> 1 rm = (r//(r & -r)) >> 1 mm = max(lm, rm) r -= 1 while l < r: if r <= rm: yield r if l <= lm: yield l l >>= 1 r >>= 1 while l: if l <= mm: yield l l >>= 1 def propagates(self, ids): num = self.num g = self.g h = self.h for i in reversed(ids): v = self.lazy[i] if v is None: continue # ここ!!!!!!!!!!!!! # ここ!!!!!!!!!!!!! newv = v newv[1] -= 1 # ここ!!!!!!!!!!!!! # ここ!!!!!!!!!!!!! if (i << 1) < num: self.lazy[i << 1] = h(self.lazy[i << 1], newv) self.lazy[(i << 1)+1] = h(self.lazy[(i << 1)+1], newv) self.seg[i << 1] = g(self.seg[i << 1], newv) self.seg[(i << 1)+1] = g(self.seg[(i << 1)+1], newv) self.lazy[i] = None def query(self, l, r): f = self.f if self.flag: *ids, = self.gindex(l, r) self.propagates(ids) ansl = ansr = self.unit l += self.num r += self.num-1 if l == r: return self.seg[l] while l < r: if l & 1: ansl = f(ansl, self.seg[l]) l += 1 if r & 1 == 0: ansr = f(self.seg[r], ansr) r -= 1 l >>= 1 r >>= 1 if l == r: ansl = f(ansl, self.seg[l]) return f(ansl, ansr) def update1(self, i, x): i += self.num f = self.f self.seg[i] = self.g(self.seg[i], x) while i: i >>= 1 self.seg[i] = f(self.seg[i << 1], self.seg[(i << 1)+1]) def update2(self, l, r, x): self.flag = True *ids, = self.gindex(l, r) self.propagates(ids) num = self.num f = self.f g = self.g h = self.h l += num r += num-1 if l == r: self.seg[l] = g(self.seg[l], x) for i in ids: self.seg[i] = f(self.seg[i << 1], self.seg[(i << 1)+1]) return while l < r: if l & 1: if l < num: self.lazy[l] = h(self.lazy[l], x) self.seg[l] = g(self.seg[l], x) l += 1 if r & 1 == 0: if r < num: self.lazy[r] = h(self.lazy[r], x) self.seg[r] = g(self.seg[r], x) r -= 1 l >>= 1 r >>= 1 x = f(x, x) if l == r: self.lazy[l] = h(self.lazy[l], x) self.seg[l] = g(self.seg[l], x) for i in ids: self.seg[i] = f(self.seg[i << 1], self.seg[(i << 1)+1]) def update(self, i, x): if type(i) is int: self.update1(i, x) else: self.update2(i[0], i[1], x) def f(x,y): if type(x[1]) is int: return [x[0],x[1]+1] return [[x[i][j]+y[i][j] for j in range(len(x[i]))]for i in range(len(x))] def g(x,yy): y,n=yy y=matpow(y,n) return matprod(y,x) def h(xx,yy): if xx is None: return yy x,n=xx y,n=yy return [matprod(y,x),n] n,q=map(int,input().split()) seg=SegmentTree(n,[[[1],[0]]]*n,[[0],[0]],f,g,h) theta=[0]*n length=[1]*n for _ in range(q): query=list(map(int,input().split())) if query[0]==0: _,i,x=query thetaa=x-theta[i-1] seg.update([i-1,n],[[[cos(radians(thetaa)),-sin(radians(thetaa))],[sin(radians(thetaa)),cos(radians(thetaa))]],1]) theta[i-1]=x elif query[0]==1: _,i,x=query seg.update(i-1,[[[x/length[i-1],0],[0,x/length[i-1]]],1]) length[i-1]=x else: _,i=query x,y=seg.query(0,i) print('{:.9f}'.format(x[0]),'{:.9f}'.format(y[0]))