#include //#include //#pragma GCC optimize("Ofast") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() #define fi first #define se second typedef long long ll; typedef vector vec; typedef vector mat; ll N,M,H,W,Q,K,A,B; string S; typedef pair P; const ll INF = (1LL<<60); template class modint{ public: ll x; modint(){x = 0;} modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){} modint operator-(){ return x == 0 ? 0 : mod - x; } modint& operator+=(const modint& a){ if((x += a.x) >= mod) x -= mod; return *this; } modint operator+(const modint& a) const{ return modint(*this) += a; } modint& operator-=(const modint& a){ if((x -= a.x) < 0) x += mod; return *this; } modint operator-(const modint& a) const{ return modint(*this) -= a; } modint& operator*=(const modint& a){ (x *= a.x)%=mod; return *this; } modint operator*(const modint& a) const{ return modint(*this) *= a; } modint pow(unsigned long long pw) const{ modint res(1), comp(*this); while(pw){ if(pw&1) res *= comp; comp *= comp; pw >>= 1; } return res; } //以下、modが素数のときのみ modint inv() const{ return modint(*this).pow(mod - 2); } modint& operator/=(const modint &a){ (x *= a.inv().x)%=mod; return *this; } modint operator/(const modint &a) const{ return modint(*this) /= a; } }; using mint = modint<360>; ostream& operator<<(ostream& os, const mint& a){ os << a.x; return os; } using vm = vector; using Pd = pair; vector my_cos(360), my_sin(360); struct arm{ //groupではlazy, elemでは真値 mint theta; double len; //elemのみ Pd v; arm() : theta(0), len(1), v(1, 0) {} arm(int l) : theta(0), len(l) {v = make_pair(l, 0);} void set_v(){ v = make_pair(my_cos[theta.x] * len, my_sin[theta.x] * len); } arm &operator += (const arm &a){ v.fi += a.v.fi; v.se += a.v.se; return *this; } const arm operator + (const arm &a){ return arm(*this) += a; } }; int main() { cin>>N>>Q; const int sz = 317, num = 317; vector group(num, arm(sz)), elem(num * sz, arm()); const long double pi = acos(-1); rep(i, 360){ long double phi = pi * i / 180; my_cos[i] = cos(phi); my_sin[i] = sin(phi); } rep(_, Q){ int i, x, id; cin>>A>>i; --i; id = i / sz; if(A == 1){ cin>>x; if(group[id].theta.x != 0){ reps(j, id * sz, (id + 1) * sz) { elem[j].theta += group[id].theta; elem[j].set_v(); } } elem[i].len = x; elem[i].set_v(); group[id] = accumulate(elem.begin() + id * sz, elem.begin() + (id + 1) * sz, arm(0)); group[id].theta = 0; }else if(A == 0){ cin>>x; reps(j, id * sz, (id + 1) * sz) { elem[j].theta += group[id].theta; if(j >= i) elem[j].theta += x; elem[j].set_v(); } group[id] = accumulate(elem.begin() + id * sz, elem.begin() + (id + 1) * sz, arm(0)); group[id].theta = 0; reps(j, id + 1, num) group[j].theta += x; }else{ Pd res(0, 0); rep(j, id) { int temp = group[j].theta.x; Pd &p = group[j].v; res.fi += p.fi * my_cos[temp] - p.se * my_sin[temp]; res.se += p.fi * my_sin[temp] + p.se * my_cos[temp]; } reps(j, id * sz, (id + 1) * sz) { elem[j].theta += group[id].theta; elem[j].set_v(); if(j <= i) { res.fi += elem[j].v.fi; res.se += elem[j].v.se; } } cout<