#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 MatG{ ll h=0, w=0; //h行w列 vector> mat; MatG(){} MatG(ll h_, ll w_, T x) { init(h_, w_, x); } MatG(ll h_, ll w_) { init(h_, w_); } MatG(ll h_, ll w_, string c) { init(h_, w_, c); } void init(ll h_, ll w_, T x){ h=h_; w=w_; mat.assign(h, vector(w,x)); } void init(ll h_, ll w_){ init(h_,w_,T()); } void init(ll h_, ll w_, string c){ init(h_, w_); if(c=="E")E(); } ll H() const { return h; } ll W() const { return w; } vector &operator[](ll i) { return mat[i]; } const vector &operator[](ll i) const { return mat[i]; } MatG &operator+=(const MatG &B) {REP(i,h)REP(j,w) mat[i][j]+=B[i][j];return *this;} MatG operator+(const MatG &B) const {return MatG(*this) += B;} MatG operator*(const MatG &B) const { MatG ret(h, B.W()); REP(i, h) REP(j, B.W()) REP(k, w) ret[i][j] += mat[i][k] * B[k][j]; return move(ret); } vector operator*(const vector &v) const { vector ret(v.size()); REP(i, this->h) REP(j, this->w) ret[i] += this->mat[i][j] * v[j]; return move(ret); } MatG Pow(ll N) const { MatG ret(*this), a(*this); for (ll n=N-1; n>0; n>>=1, a=a*a){ if (n&1) ret=ret*a; } return move(ret); } MatG t() const { MatG ret(this->w, this->h); REP(i, this->w) REP(j, this->h) ret[i][j] = this->mat[j][i]; return move(ret); } void E(){ rep(i, 0, min(h,w)-1) mat[i][i]=1; } //void dump() { ::dump(mat); } MatG(MatG &&B){ *this=move(B); } //以下、ムーブ対応 MatG(MatG const &B){ *this=B; } MatG &operator=(MatG &&B){ h=B.h; w=B.w; mat.swap(B.mat); return *this; } MatG &operator=(MatG const &B){ h=B.h; w=B.w; mat=B.mat; return *this; } }; using Mat = MatG
; 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):f(f){ Init(v, ti); } void Init(vector &v, T ti){ 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] = move(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; } }; void solve() { ll n,q; cin >> n >> q; vdd rads(n); vll ds(n,1); Mat mate(4,4,"E"); Mat inimat(4,4,"E"); inimat[0][2]=1.; inimat[1][3]=1.; vector ini(n,inimat); auto f=[&](Mat x,Mat y){ Mat ret(4,4); ret[0][0]=1.; ret[1][1]=1.; REP(i, 4) rep(j,2,3) REP(k, 4) ret[i][j] += y[i][k] * x[k][j]; return ret; }; SegmentTree sgt( ini, //全初期値の入ったvector f, //データ同士の合成関数 mate //単位元 ); auto setmt=[&](Mat &mt, dd d, dd rad){ mt[0][0]=1.; mt[0][2]=d*cos(rad); mt[0][3]=-d*sin(rad); mt[1][1]=1.; mt[1][2]=d*sin(rad); mt[1][3]=d*cos(rad); mt[2][2]= cos(rad); mt[2][3]=-sin(rad); mt[3][2]=sin(rad); mt[3][3]=cos(rad); }; 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.; Mat mt(4,4); setmt(mt,(dd)ds[i],rx); sgt.Set(i,mt); rads[i]=rx; } else if (kind==1){ ll i,x; cin >> i >> x; i--; Mat mt(4,4); setmt(mt,(dd)x,rads[i]); sgt.Set(i,mt); ds[i]=x; } else{//kind==2 ll i; cin >> i;i--; Mat A = sgt.Range(0,i); vdd bg{0.,0.,1.,0.}; vdd ans=A*bg; cout << ans[0] << " " << ans[1] << '\n'; } } } int main(){ #if 1 solve(); #else ll t; cin >> t; rep(i, 0, t-1){ solve(); } #endif return 0; }