#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
const int N = 300000 + 5;
const int M = 360;
const long double Pi = acosl((long double)-1.0);
int n, m;
int al[N], a[N];
int x[N], y[N], z[N];
struct pt {
  long double x, y;
  pt(long double _x = 0.0, long double _y = 0.0) : x(_x), y(_y) {}
};
pt operator+(pt l, const pt& r) {
  l.x += r.x;
  l.y += r.y;
  return l;
}
pt operator*(pt l, const long double r) {
  l.x *= r;
  l.y *= r;
  return l;
}
pt p[N];
pt t[4 * N];
long long L[N];
int ad[4 * N];
int Al[N];
void build(int v, int tl, int tr) {
  if (tl == tr) {
    L[tl] = 1;
    a[tl] = 0;
    t[v] = pt(1.0, 0);
    return;
  }
  int tm = (tl + tr) / 2;
  build(v + v, tl, tm);
  build(v + v + 1, tm + 1, tr);
  t[v] = t[v + v] + t[v + v + 1];
}
void rotate(pt& a, int b) {
  pt d(cosl(-Pi * b / 180.0), sinl(-Pi * b / 180));
  a = pt(a.x * d.x - a.y * d.y, a.x * d.y + a.y * d.x);
}
void push(int v) {
  if (ad[v]) {
    ad[v + v] = (ad[v] + ad[v + v]) % M;
    ad[v + v + 1] = (ad[v] + ad[v + v + 1]) % M;
    rotate(t[v + v], ad[v]);
    rotate(t[v + v + 1], ad[v]);
    ad[v] = 0;
  }
}
void updateLen(int v, int tl, int tr, int pos, int l) {
  if (tl == tr) {
    long double D = (long double)(L[tl] + l) / L[tl];
    L[tl] += l;
    t[v] = t[v] * D;
    return;
  }
  push(v);
  int tm = (tl + tr) / 2;
  if (pos <= tm)
    updateLen(v + v, tl, tm, pos, l);
  else
    updateLen(v + v + 1, tm + 1, tr, pos, l);
  t[v] = t[v + v] + t[v + v + 1];
}
void updateAng(int v, int tl, int tr, int l, int r, int ang) {
  if (l <= tl && tr <= r) {
    rotate(t[v], ang);
    ad[v] = (ad[v] + ang) % M;
    return;
  }
  push(v);
  int tm = (tl + tr) / 2;
  if (l <= tm) updateAng(v + v, tl, tm, l, r, ang);
  if (r > tm) updateAng(v + v + 1, tm + 1, tr, l, r, ang);
  t[v] = t[v + v] + t[v + v + 1];
}
void solve() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= (int)(n); ++i) {
    al[i] = 0;
    a[i] = 1;
  }
  for (int i = 1; i <= (int)(m); ++i) {
    scanf("%d%d%d", &x[i], &y[i], &z[i]);
  }
  build(1, 1, n);
  for (int i = 1; i <= (int)(m); ++i) {
    if (x[i] == 1) {
      updateLen(1, 1, n, y[i], z[i]);
    }
    if (x[i] == 2) {
      updateAng(1, 1, n, y[i], n, z[i]);
    }
    cout << t[1].x << " " << t[1].y << endl;
  }
}
long long RAND() {
  return ((long long)rand() << 32) + ((long long)rand() << 16) + rand();
}
void testgen() {
  FILE* f = fopen("input.txt", "w");
  fclose(f);
}
int main() {
  cout << fixed;
  cout.precision(10);
  cerr << fixed;
  cerr.precision(3);
  solve();
  return 0;
}
