#include using namespace std; struct seg { using T=pair>; int n = 1; vector v; seg(int n_) { while (n < n_) n *= 2; v.resize(2 * n - 1); for (int i = 0; i < n; ++i) { v[i + n - 1] = make_pair(0, 1); } for (int i = n - 2; i >= 0; --i) { v[i] = merge(v[2 * i + 1], v[2 * i + 2]); } } void update(int k, double rho, double theta) { k += n - 1; v[k] = make_pair(theta, polar(rho, theta)); while (k) k = (k - 1) / 2, v[k] = merge(v[2 * k + 1], v[2 * k + 2]); } T query(int a, int b) { return query(0, n, a, b, 0); } T query(int l, int r, int a, int b, int k) { if (r <= a || b <= l) return make_pair(0, 0); if (a <= l && r <= b) return v[k]; auto vl = query(l, (l + r) / 2, a, b, 2 * k + 1); auto vr = query((l + r) / 2, r, a, b, 2 * k + 2); return merge(vl, vr); } T merge(T a, T b) { auto ret = make_pair(a.first + b.first, a.second + polar(1., a.first) * b.second); return ret; } }; long double pi = 4 * atan(1); main() { int N, Q; cin >> N >> Q; seg s(N); while (Q--) { int q, i; cin >> q >> i; --i; double r = abs(s.v[i + s.n - 1].second); double a = arg(s.v[i + s.n - 1].second); if (q == 2) { auto p = s.query(0, i + 1).second; cout << p.real() << " " << p.imag() << endl; } else { double x; cin >> x; if (q == 0) a = x / 180 * pi; else r = x; s.update(i, r, a); } } }