#pragma GCC optimize("O3") #include #define ll long long #define rep(i,n) for(ll i=0;i<(n);i++) #define pll pair #define pii pair #define pq priority_queue #define pb push_back #define eb emplace_back #define fi first #define se second #define endl '\n' #define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define lb(c,x) distance(c.begin(),lower_bound(all(c),x)) #define ub(c,x) distance(c.begin(),upper_bound(all(c),x)) using namespace std; struct LazySegmentTree{ private: ll n; vector node, lazy; public: LazySegmentTree(vector v){ ll sz=(ll)v.size(); n=1; while(n=0;i--) node[i]=node[2*i+1]+node[2*i+2]; } void eval(ll k,ll l,ll r){ if(lazy[k]!=0){ node[k]+=lazy[k]; if(r-l>1){ lazy[2*k+1]+=lazy[k]/2.0; lazy[2*k+2]+=lazy[k]/2.0; } lazy[k]=0.0; } } void add(ll a,ll b,double x,ll k=0,ll l=0,ll r=-1){ if(r<0) r=n; eval(k,l,r); if(b<=l || r<=a) return; if(a<=l && r<=b){ lazy[k]+=(double)(r-l)*x; eval(k,l,r); } else{ add(a,b,x,2*k+1,l,(l+r)/2); add(a,b,x,2*k+2,(l+r)/2,r); node[k]=node[2*k+1]+node[2*k+2]; } } double getsum(ll a,ll b,ll k=0,ll l=0,ll r=-1){ if(r<0) r=n; if(b<=l || r<=a) return 0.0; eval(k,l,r); if(a<=l && r<=b) return node[k]; double vl=getsum(a,b,2*k+1,l,(l+r)/2); double vr=getsum(a,b,2*k+2,(l+r)/2,r); return vl+vr; } }; const double pi=acos(-1); int main(){ int n,q; cin >> n >> q; vector u(n+1),v(n+1),ang(n+1),d(n+1,1.0); LazySegmentTree segx=LazySegmentTree(u); LazySegmentTree segy=LazySegmentTree(v); LazySegmentTree sega=LazySegmentTree(ang); segx.add(0,n+1,1.0); rep(i,q){ ll t; cin >> t; if(t==0){ ll i,x; cin >> i >> x; i--; segx.add(i,i+1,-d[i]*cos((sega.getsum(i,i+1)/180.0)*pi)); segy.add(i,i+1,-d[i]*sin((sega.getsum(i,i+1)/180.0)*pi)); segx.add(i,i+1,d[i]*cos((x/180.0)*pi)); segy.add(i,i+1,d[i]*sin((x/180.0)*pi)); sega.add(i,n+1,x); } if(t==1){ ll i,x; cin >> i >> x; i--; segx.add(i,i+1,(x-d[i])*cos((sega.getsum(i,i+1)/180.0)*pi)); segy.add(i,i+1,(x-d[i])*sin((sega.getsum(i,i+1)/180.0)*pi)); d[i]=x; } if(t==2){ ll i; cin >> i; i--; double vx=segx.getsum(0,i+1); double vy=segy.getsum(0,i+1); cout << setprecision(30) << fixed; cout << vx << " " << vy << endl; } } return 0; }