#ifndef LOCAL #include using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif using S = complex; S op(S a, S b) { return a + b; } S e() { return S{0, 0}; } using F = S; F id() { return F{1, 0}; } F composition(F f, F g) { return f * g; } S mapping(F f, S x) { return x * f; } #include #include using deg = atcoder::static_modint<360>; void solve() { int N, Q; cin >> N >> Q; vector D(N, 1); vector T(N); atcoder::lazy_segtree seg(vector(N, S{1, 0})); while (Q--) { int o; cin >> o; if (o == 0) { int p, x; cin >> p >> x; p--; deg y = x - T[p]; double th = M_PI * y.val() / 180; seg.apply(p, N, F{cos(th), sin(th)}); T[p] = deg::raw(x); } else if (o == 1) { int p, x; cin >> p >> x; p--; double y = double(x) / D[p]; seg.set(p, seg.get(p) * y); D[p] = x; } else { int p; cin >> p; S ans = seg.prod(0, p); cout << fixed << setprecision(16) << ans.real() << " " << ans.imag() << '\n'; } } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int tt = 1; // std::cin >> tt; while (tt--) { solve(); } }