#include using namespace std; const double PI = acos(-1); template struct BIT { int n; vector dat; BIT(int n=0){ initialize(n); } void initialize(int nin){ n = nin; dat.assign(n, 0); } T sum(int i){ T s = 0; while(i >= 0){ s += dat[i]; i = (i & (i+1)) - 1; } return s; } T sum_between(int i, int j){ return sum(j) - sum(i-1); } void plus(int i, T x){ while(i < n){ dat[i] += x; i |= i+1; } } // a[0]+...+a[ret] >= x int lower_bound(T x){ if(x < 0) return -1; int ret = -1; int k = 1; while(2*k <= n) k <<= 1; for( ;k>0; k>>=1){ if(ret+k < n && dat[ret+k] < x){ x -= dat[ret+k]; ret += k; } } return ret + 1; } }; template struct LazySegtree { int n, n_org; vector dat; vector laz; Func_mf merge_functions; Func_op operate; Func_mv merge_values; F fe; T te; LazySegtree(){} LazySegtree(int n_org, Func_mf merge_functions, Func_op operate, Func_mv merge_values, F fe, T te): n_org(n_org), merge_functions(merge_functions), operate(operate), merge_values(merge_values), fe(fe), te(te){ n = 1; while(n < n_org) n <<= 1; dat.assign(2*n-1, te); laz.assign(2*n-1, fe); } void build(vector& A){ for(int k=0; k=0; k--) dat[k] = merge_values(dat[2*k+1], dat[2*k+2]); } void eval(int k, int w){ if(laz[k] == fe) return; operate(dat[k], laz[k], w); if(k < n-1){ merge_functions(laz[2*k+1], laz[k]); merge_functions(laz[2*k+2], laz[k]); } laz[k] = fe; } void update_between(int a, int b, F x){ update(a, b+1, x, 0, 0, n); } void update(int a, int b, F x, int k, int lb, int rb){ eval(k, rb-lb); if(b <= lb || rb <= a) return; if(a <= lb && rb <= b){ merge_functions(laz[k], x); eval(k, rb-lb); }else{ int mb = (lb+rb)>>1; update(a, b, x, 2*k+1, lb, mb); update(a, b, x, 2*k+2, mb, rb); dat[k] = merge_values(dat[2*k+1], dat[2*k+2]); } } T get_between(int a, int b){ return query(a, b+1, 0, 0, n); } T query(int a, int b, int k, int lb, int rb){ eval(k, rb-lb); if(rb<=a || b<=lb) return te; if(a<=lb && rb<=b) return dat[k]; int mb = (lb+rb)>>1; T vl = query(a, b, 2*k+1, lb, mb); T vr = query(a, b, 2*k+2, mb, rb); return merge_values(vl, vr); } }; typedef vector> Mat; Mat matmul(Mat A, Mat B){ assert(A[0].size() == B.size()); int N = A.size(), M = B[0].size(), K = B.size(); Mat ans(N, vector(M)); for(int i=0; i; using T = Mat; auto merge_functions = [](F& f, F& g){ f.first = matmul(g.first, f.first); f.second = matadd(matmul(g.first, f.second), g.second); }; auto operate = [](T& v, F& f, int w){ v = matadd(matmul(f.first, v), f.second); }; auto merge_values = [](T& a, T& b){ return a == Z21 ? b : a; }; F fe = {E22, Z21}; T te = Z21; return LazySegtree (N, merge_functions, operate, merge_values, fe, te); }; int main(){ int N, Q; cin >> N >> Q; auto st = make_segtree(N+1); vector L(N, 1); BIT Theta(N); auto calc = [&](int deg, Mat pos)->pair{ double theta = deg*PI/180; double x0 = pos[0][0], y0 = pos[1][0]; Mat a = {{cos(theta), -sin(theta)}, {sin(theta), cos(theta)}}; Mat b = { {-cos(theta)*x0 + sin(theta)*y0 + x0}, {-sin(theta)*x0 - cos(theta)*y0 + y0} }; return {a, b}; }; vector ini(N+1); for(int i=0; i<=N; i++) ini[i] = {{double(i)}, {0.0}}; st.build(ini); while(Q--){ int t; scanf("%d", &t); if(t == 1){ int i, x; scanf("%d %d", &i, &x); i--; int d = x - L[i]; int theta = Theta.sum(i) % 360; Mat diff = {{d*cos(theta*PI/180)}, {d*sin(theta*PI/180)}}; st.update_between(i+1, N, {E22, diff}); L[i] = x; }else if(t == 0){ int i, x; scanf("%d %d", &i, &x); i--; auto pos = st.get_between(i, i); int diff = x - Theta.sum_between(i, i); auto f = calc(diff, pos); st.update_between(i+1, N, f); Theta.plus(i, diff); }else{ int i; scanf("%d", &i); auto ans = st.get_between(i, i); printf("%.10lf %.10lf\n", ans[0][0], ans[1][0]); } } return 0; }