#include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double dbl; typedef long double ld; #define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i) #define REP(i, b) FOR(i, 0, b) #define FORLL(i, a, b) for(ll i = (ll)(a); i < (ll)(b); ++i) #define REPLL(i, b) FORLL(i, 0, b) #define ALL(x) (x).begin(),(x).end() const int INF = 1e+9; constexpr int mod(int n) {return n % 1000000007;} template inline Head max(Head head, Tail... tail) {for(Head i: initializer_list{tail...}) if(head < i) head = i; return head;} template inline Head min(Head head, Tail... tail) {for(Head i: initializer_list{tail...}) if(head > i) head = i; return head;} template inline void chmax(T &v, U... a) {v = ::max(v, a...);} template inline void chmin(T &v, U... a) {v = ::min(v, a...);} inline void read(char &v) {v = getchar();} inline void read(int &v) {assert(scanf("%d", &v));} inline void read(ll &v) {assert(scanf("%lld", &v));} inline void read(ull &v) {assert(scanf("%llu", &v));} inline void read(dbl &v) {assert(scanf("%lf", &v));} inline void read(ld &v) {assert(scanf("%Lf", &v));} inline void read(string &v){v.clear(); char buf[512]; do read(*buf); while(*buf == ' ' || *buf == '\n'); for(int pt = 1;;) {read(buf[pt]); if(buf[pt] == ' ' || buf[pt] == '\n') {v.append(buf, pt); break;} if(++pt >= 512) {v.append(buf, 512); pt = 0;}}} template inline void read(vector &v) {int N = v.size(); REP(i, N) read(v[i]);} template inline void read(array &v) {REP(i, N) read(v[i]);} template inline void read(Head &head, Tail &... tail) {read(head); read(tail...);} bool write_space = false; inline void write() {if(write_space) putchar(' '); else write_space = true;} inline void write(char v) {if(v == '\n' || v == ' ') write_space = false; else write(); putchar(v);} inline void write(const char *v){if(!*v) {write(); return;} if(*v != '\n' && *v != ' ') write(); while(*v) putchar(*(v++)); --v; write_space = *v != '\n' && *v != ' ';} inline void write(string &v){write(v.c_str());} inline void write(int v) {write(); printf("%d", v);} inline void write(ll v) {write(); printf("%lld", v);} inline void write(ull v) {write(); printf("%llu", v);} inline void write(dbl v) {write(); printf("%.16f", v);} inline void write(ld v) {write(); printf("%.32Lf", v);} template inline void write(vector &v) {int N = size(v); REP(i, N) write(v[i]); write('\n');} template inline void write(array &v) {REP(i, N) write(v[i]); write('\n');} template inline void write(Head head, Tail... tail) {write(head); write(tail...);} ld cos_p[360]; void tri() { const ld pi_180 = 3.141592653589793238462643383279502884L / 180; REP(i, 360) { cos_p[i] = cosl(pi_180 * i); } } int main() { tri(); int n, q, u = 1; vector arm, joint; vector> pt; vector deg; read(n, q); arm.resize(n); REP(i, n) arm[i] = 1; joint.resize(n); pt.resize(n + 1); deg.resize(n + 1); REP(count, q) { int a, i; read(a, i); switch(a) { case 0: read(joint[i - 1]); if(u > i) u = i; break; case 1: read(arm[i - 1]); if(u > i) u = i; break; case 2: for(;u <= i;u++) { deg[u] = (deg[u - 1] + joint[u - 1]) % 360; pt[u][0] = pt[u - 1][0] + cos_p[deg[u]] * arm[u - 1]; pt[u][1] = pt[u - 1][1] + cos_p[(deg[u] + 270) % 360] * arm[u - 1]; } write(pt[i][0], pt[i][1], '\n'); } } return 0; }