#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include //#include //#include //#include using namespace std; //#define int long long typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; constexpr ll mod = 1000000007; const ll INF = mod * mod; typedef pairP; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) #define all(v) (v).begin(),(v).end() typedef pair LP; typedef double ld; typedef pair LDP; const ld eps = 1e-8; const ld pi = acosl(-1.0); ll mod_pow(ll x, ll n, ll m = mod) { if (x >= m)x %= m; ll res = 1; while (n) { if (n & 1)res = res * x % m; x = x * x % m; n >>= 1; } return res; } struct modint { ll n; modint() :n(0) { ; } modint(ll m) :n(m) { if (n >= mod)n %= mod; else if (n < 0)n = (n % mod + mod) % mod; } operator int() { return n; } }; bool operator==(modint a, modint b) { return a.n == b.n; } modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; } modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; } modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; } modint operator+(modint a, modint b) { return a += b; } modint operator-(modint a, modint b) { return a -= b; } modint operator*(modint a, modint b) { return a *= b; } modint operator^(modint a, ll n) { if (n == 0)return modint(1); modint res = (a * a) ^ (n / 2); if (n % 2)res = res * a; return res; } ll inv(ll a, ll p) { return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p); } modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); } const int max_n = 1 << 19; modint fact[max_n], factinv[max_n]; void init_f() { fact[0] = modint(1); for (int i = 0; i < max_n - 1; i++) { fact[i + 1] = fact[i] * modint(i + 1); } factinv[max_n - 1] = modint(1) / fact[max_n - 1]; for (int i = max_n - 2; i >= 0; i--) { factinv[i] = factinv[i + 1] * modint(i + 1); } } modint comb(int a, int b) { if (a < 0 || b < 0 || a < b)return 0; return fact[a] * factinv[b] * factinv[a - b]; } int gcd(int a, int b) { if (a < b)swap(a, b); while (b) { int r = a % b; a = b; b = r; } return a; } template struct SegT { private: int sz; vector node; T init_c; function f; public: SegT(vector v, T _init_c, function _f) { init_c = _init_c; f = _f; int n = v.size(); sz = 1; while (sz < n)sz *= 2; node.resize(2 * sz - 1, init_c); rep(i, n) { node[i + sz - 1] = v[i]; } per(i, sz - 1) { node[i] = f(node[2 * i + 1], node[2 * i + 2]); } } SegT(int n, T _init_c, function _f) { init_c = _init_c; f = _f; sz = 1; while (sz < n)sz *= 2; node.resize(2 * sz - 1, init_c); } void update(int k, T a) { k += sz - 1; node[k] = a; while (k > 0) { k = (k - 1) / 2; node[k] = f(node[k * 2 + 1], node[k * 2 + 2]); } } T query(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0)r = sz; if (r <= a || b <= l)return init_c; else if (a <= l && r <= b)return node[k]; else { T vl = query(a, b, k * 2 + 1, l, (l + r) / 2); T vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return f(vl, vr); } } }; struct ste { ld d, t,st; }; void solve() { int n, q; cin >> n >> q; auto f = [&](ste a, ste b)->ste { if (a.d == 0)return b; if (b.d == 0)return a; ld d, t,st; st = a.st + b.st; ld x = a.d * cosl(a.t); ld y = a.d * sinl(a.t); ld nx = x + b.d * cosl(a.st+b.t); ld ny = y + b.d * sinl(a.st+b.t); d = sqrtl(nx * nx + ny * ny); t = atan2l(ny, nx); return { d,t,st }; }; SegT st(n, { 0,0,0 }, f); rep(i, n)st.update(i, { 1,0,0}); /*rep1(i, 3) { LDP p = st.query(0, i); ld x = p.first * cosl(p.second); ld y = p.first * sinl(p.second); cout << x << " " << y << "\n"; }*/ vector ls(n, 1), args(n, 0); rep(i, q) { int t; cin >> t; if (t == 0) { int v; cin >> v; v--; ld x; cin >> x; x *= pi / 180.0; args[v] = x; st.update(v, { ls[v],args[v],args[v] }); } else if (t == 1) { int v; cin >> v; v--; ld x; cin >> x; ls[v] = x; st.update(v, { ls[v],args[v],args[v] }); } else { int v; cin >> v; ste p = st.query(0, v); //cout << "? " << p.first << " " << p.second << "\n"; ld x = p.d * cosl(p.t); ld y = p.d * sinl(p.t); cout << x << " " << y << "\n"; } } } signed main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); //init_f(); //init(); //expr(); //int t; cin >> t; rep(i, t) solve(); return 0; }