from math import sin, cos, pi p = pi / 180 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) n, q = map(int, input().split()) def merge(a, b): (x1, y1), t1 = a (x2, y2), t2 = b x = x1 + x2*cos(t1*p) - y2*sin(t1*p) y = y1 + x2*sin(t1*p) + y2 * cos(t1*p) return (x, y), t1+t2 seg = SegmentTree([((1, 0), 0) for _ in range(n)], merge, [[0, 0], 0]) d = [1] * n th = [0] * n for _ in range(q): qu, *x = map(int, input().split()) if qu == 2: print(*seg.get_segment(0, x[0])[0]) else: a, b = x if qu == 0: th[a-1] = b c = ((d[a-1] * cos(b*p), d[a-1] * sin(b*p)), b) else: d[a-1] = b e = th[a-1] c = ((b * cos(e*p), b * sin(e*p)), e) seg.update(a-1, c)