#include <bits/stdc++.h>
using namespace std;
struct node {
  int l;
  int r;
  double x;
  double y;
  double a;
} s[1200010];
int n;
void pushup(int cur) {
  double r, a;
  r = sqrt(s[2 * cur + 1].x * s[2 * cur + 1].x +
           s[2 * cur + 1].y * s[2 * cur + 1].y);
  a = atan2(s[2 * cur + 1].y, s[2 * cur + 1].x);
  s[cur].x = s[2 * cur].x + r * cos(s[2 * cur].a + a);
  s[cur].y = s[2 * cur].y + r * sin(s[2 * cur].a + a);
  s[cur].a = s[2 * cur].a + s[2 * cur + 1].a;
  return;
}
void build(int l, int r, int cur) {
  int m;
  s[cur].l = l;
  s[cur].r = r;
  if (l + 1 == r) {
    s[cur].x = 1.0;
    s[cur].y = 0.0;
    s[cur].a = 0.0;
    return;
  }
  m = (l + r) / 2;
  build(l, m, 2 * cur);
  build(m, r, 2 * cur + 1);
  pushup(cur);
  return;
}
void update(int tar, double valr, double vala, int cur) {
  double r, a;
  if (s[cur].l + 1 == s[cur].r) {
    r = sqrt(s[cur].x * s[cur].x + s[cur].y * s[cur].y);
    a = atan2(s[cur].y, s[cur].x);
    r += valr, a += vala;
    s[cur].x = r * cos(a);
    s[cur].y = r * sin(a);
    s[cur].a = a;
    return;
  }
  if (tar <= s[2 * cur].r)
    update(tar, valr, vala, 2 * cur);
  else
    update(tar, valr, vala, 2 * cur + 1);
  pushup(cur);
  return;
}
int main() {
  double val;
  int q, op, tar;
  while (scanf("%d%d", &n, &q) != EOF) {
    build(0, n, 1);
    while (q--) {
      scanf("%d%d%lf", &op, &tar, &val);
      if (op == 1)
        update(tar, val, 0.0, 1);
      else
        update(tar, 0.0, (1.0 - val / 360.0) * 2 * acos(-1.0), 1);
      printf("%.10f %.10f\n", s[1].x, s[1].y);
    }
  }
  return 0;
}
