#include "bits/stdc++.h" using namespace std; using ll=long long; using vll=vector< ll>; using vvll=vector< vll>; using vvvll=vector< vvll>; using vvvvll=vector; constexpr ll INF = 1LL << 60; struct Fast{ //cin,cout高速化のおまじない+桁数指定 Fast(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(std::numeric_limits::max_digits10); } } fast; #define REPS(i, S, E) for (ll i = (S); i <= (E); i++) #define REP(i, N) REPS(i, 0, (N)-1) #define DEPS(i, S, E) for (ll i = (E); i >= (S); i--) #define DEP(i, N) DEPS(i, 0, (N)-1) #define rep(i, S, E) for (ll i = (S); i <= (E); i++) #define dep(i, E, S) for (ll i = (E); i >= (S); i--) #define each(e, v) for (auto&& e : v) #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; } template inline T MaxE(vector&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmax(m,v[i]); return m; } template inline T MinE(vector&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmin(m,v[i]); return m; } template inline T MaxE(vector &v) { return MaxE(v,0,(ll)v.size()-1); } template inline T MinE(vector &v) { return MinE(v,0,(ll)v.size()-1); } template inline T Sum(vector &v,ll S,ll E){ T s=T(); rep(i,S,E)s+=v[i]; return s; } template inline T Sum(vector &v) { return Sum(v,0,v.size()-1); } template inline ll sz(T &v){ return (ll)v.size(); } template inline T POW(T a, ll n){ T r=1; for (; n>0; n>>=1, a*=a){ if (n&1)r*=a; } return r; } inline ll POW(int a, ll n){ return POW((ll)a, n); } inline ll CEIL(ll a, ll b){ return (a+b-1)/b; } using dd=double; using vdd=vector< dd>; using vvdd=vector< vdd>; template struct SegmentTree{ using F = function; vector dat; //第i要素 dat[i+n-1] ll n; //要素数以上の最小の 2のべき乗 F f; T ti; SegmentTree(){} SegmentTree(vector &v, F f, T ti){ Init(v, f, ti); } void Init(vector &v, F f, T ti){ this->f=f; this->ti=ti; for (n = 1; n < (ll)v.size(); n *= 2); dat.resize(2*n-1, ti); REP(i, (ll)v.size()) { dat[i+n-1] = v[i]; }//初期化 DEP(i, n-1) { dat[i] = f(dat[2*i+1], dat[2*i+2]); }//構築 } void Set(ll i, T x){ //第i要素にxをセット i += n-1; dat[i] = x; while (i>0) { i=(i-1)/2; dat[i]=f(dat[2*i+1], dat[2*i+2]); } } T Range(ll a, ll b) { return range(a, b+1, 0, 0, n); } T operator [] (ll i) { return dat[i+n-1]; } void Dump(ll w=5){ REP(i, n) for (ll k=i+n-1, m=1, p=1; k>=0; p=m, m*=k%2, k=(k==0)?-1:(k-1)/2){ if (m) cerr << ((k= n-1) return k-(n-1); //葉なら見つかった→位置return ll i = findL(a, b, x, 2*k+1, l, (l+r)/2); //左部分木探す if (i==b) i = findL(a, b, x, 2*k+2, (l+r)/2, r); //左になければ右 return i; } ll FindR(ll a, ll b, T x) { return findR(a, b+1, x, 0, 0, n); } ll findR(ll a, ll b, T x, ll k, ll l, ll r){ //[l,r)内最右 なければa-1 if (r<=a || b<=l || f(dat[k], x)!=dat[k]) return a-1; //範囲外or満たさない if (k >= n-1) return k-(n-1); //葉なら見つかった→位置return ll i = findR(a, b, x, 2*k+2, (l+r)/2, r); //右部分木探す if (i==a-1) i = findR(a, b, x, 2*k+1, l, (l+r)/2); //右になければ左 return i; } }; //pair用テンプレート using pll=pair; using vpll=vector< pll>; using vvpll=vector; template inline pair& operator+=(pair &a,const pair &b){ a.first+=b.first; a.second+=b.second; return a; } template inline pair& operator-=(pair &a,const pair &b){ a.first-=b.first; a.second-=b.second; return a; } template inline pair& operator*=(pair &a,const pair &b){ a.first*=b.first; a.second*=b.second; return a; } template inline pair& operator/=(pair &a,const pair &b){ a.first/=b.first; a.second/=b.second; return a; } template inline pair& operator%=(pair &a,const pair &b){ a.first%=b.first; a.second%=b.second; return a; } template inline pair& operator+=(pair &a,R b){ a.first+=b; a.second+=b; return a; } template inline pair& operator-=(pair &a,R b){ a.first-=b; a.second-=b; return a; } template inline pair& operator*=(pair &a,R b){ a.first*=b; a.second*=b; return a; } template inline pair& operator/=(pair &a,R b){ a.first/=b; a.second/=b; return a; } template inline pair& operator%=(pair &a,R b){ a.first%=b; a.second%=b; return a; } template inline pair operator+(const pair &a,R b){ pair c=a; return c+=b; } template inline pair operator-(const pair &a,R b){ pair c=a; return c-=b; } template inline pair operator*(const pair &a,R b){ pair c=a; return c*=b; } template inline pair operator/(const pair &a,R b){ pair c=a; return c/=b; } template inline pair operator%(const pair &a,R b){ pair c=a; return c%=b; } template inline pair operator-(R b,const pair &a){ pair c=-a; return c+=b; } template inline pair operator-(const pair &a){ pair c=a; return c*=(-1); } template inline ostream &operator<<(ostream &os,const pair &a){ return os << a.first << ' ' << a.second; } //tuple3用テンプレート using tll=tuple; using vtll=vector< tll>; using vvtll=vector; template inline tuple& operator+=(tuple &a,const tuple &b){ get<0>(a)+=get<0>(b); get<1>(a)+=get<1>(b); get<2>(a)+=get<2>(b); return a; } template inline tuple& operator-=(tuple &a,const tuple &b){ get<0>(a)-=get<0>(b); get<1>(a)-=get<1>(b); get<2>(a)-=get<2>(b); return a; } template inline tuple& operator*=(tuple &a,const tuple &b){ get<0>(a)*=get<0>(b); get<1>(a)*=get<1>(b); get<2>(a)*=get<2>(b); return a; } template inline tuple& operator/=(tuple &a,const tuple &b){ get<0>(a)/=get<0>(b); get<1>(a)/=get<1>(b); get<2>(a)/=get<2>(b); return a; } template inline tuple& operator%=(tuple &a,const tuple &b){ get<0>(a)%=get<0>(b); get<1>(a)%=get<1>(b); get<2>(a)%=get<2>(b); return a; } template inline tuple& operator+=(tuple &a,Q b){ get<0>(a)+=b; get<1>(a)+=b; get<2>(a)+=b; return a; } template inline tuple& operator-=(tuple &a,Q b){ get<0>(a)-=b; get<1>(a)-=b; get<2>(a)-=b; return a; } template inline tuple& operator*=(tuple &a,Q b){ get<0>(a)*=b; get<1>(a)*=b; get<2>(a)*=b; return a; } template inline tuple& operator/=(tuple &a,Q b){ get<0>(a)/=b; get<1>(a)/=b; get<2>(a)/=b; return a; } template inline tuple& operator%=(tuple &a,Q b){ get<0>(a)%=b; get<1>(a)%=b; get<2>(a)%=b; return a; } template inline tuple operator+(const tuple &a,Q b){ tuple c=a; return c+=b; } template inline tuple operator-(const tuple &a,Q b){ tuple c=a; return c-=b; } template inline tuple operator*(const tuple &a,Q b){ tuple c=a; return c*=b; } template inline tuple operator/(const tuple &a,Q b){ tuple c=a; return c/=b; } template inline tuple operator%(const tuple &a,Q b){ tuple c=a; return c%=b; } template inline tuple operator-(Q b,const tuple &a){ tuple c=-a; return c+=b; } template inline tuple operator-(const tuple &a){ tuple c=a; return c*=(-1); } template inline ostream &operator<<(ostream &os,const tuple &a){ return os << get<0>(a) << ' ' << get<1>(a) << ' ' << get<2>(a); } using tdd=tuple; using vtdd=vector; void solve() { ll n,q; cin >> n >> q; vdd rad(n); vll d(n,1); vtdd v(n,{1.,0.,0.}); SegmentTree sgt( v, //全初期値の入ったvector [](tdd a, tdd b){ dd xa,ya,ta; tie(xa,ya,ta) = a; dd xb,yb,tb; tie(xb,yb,tb) = b; dd cosa=cos(ta); dd sina=sin(ta); dd xc=cosa*xb-sina*yb+xa; dd yc=sina*xb+cosa*yb+ya; dd tc=ta+tb; return tdd(xc,yc,tc); }, //データ同士の合成関数 {0.,0.,0.} //単位元 ); vector> ans; rep(qq,0,q-1){ ll kind; cin >> kind; if (kind==0){ ll i,x; cin >> i >> x; i--; dd rx=x*3.141592653589793238/180.; rad[i]=rx; sgt.Set(i,{d[i]*cos(rad[i]),d[i]*sin(rad[i]),rad[i]}); } else if (kind==1){ ll i,x; cin >> i >> x; i--; d[i]=x; sgt.Set(i,{d[i]*cos(rad[i]),d[i]*sin(rad[i]),rad[i]}); } else{//kind==2 ll i; cin >> i; i--; dd x,y,t; tie(x,y,t) = sgt.Range(0,i); ans.emplace_back(x,y); } } each(e,ans) cout << e << '\n'; } int main(){ #if 1 solve(); #else ll t; cin >> t; rep(i, 0, t-1){ solve(); } #endif return 0; }