#include <bits/stdc++.h>
using namespace std;
int pos;
double pcos[360];
double psin[360];
struct tree {
  double x, y;
  int ang;
  tree(double x = 0, double y = 0, double ang = 0) : x(x), y(y), ang(ang) {}
  tree operator+(tree a) {
    return tree(x + a.x * pcos[ang] + a.y * psin[ang],
                y - a.x * psin[ang] + a.y * pcos[ang], (ang + a.ang) % 360);
  }
} a[300000 * 4];
int main() {
  int n, m, i, x, y, z, ppos;
  scanf("%d%d", &n, &m);
  pos = 1;
  while (pos < n) pos <<= 1;
  for (i = 0; i < 360; i++) {
    pcos[i] = cos(1. * i * acos(-1) / 180);
    psin[i] = sin(1. * i * acos(-1) / 180);
  }
  for (i = 1; i <= n; i++) {
    a[pos + i - 1] = tree(1, 0, 0);
  }
  for (i = pos - 1; i >= 1; i--) a[i] = a[i * 2] + a[i * 2 + 1];
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    ppos = y + pos - 1;
    if (x == 1) {
      double len = sqrt(a[ppos].x * a[ppos].x + a[ppos].y * a[ppos].y);
      a[ppos] = tree(a[ppos].x * (len + z) / len, a[ppos].y * (len + z) / len,
                     a[ppos].ang);
    } else {
      a[ppos] = tree(a[ppos].x * pcos[z] + a[ppos].y * psin[z],
                     a[ppos].y * pcos[z] - a[ppos].x * psin[z],
                     (a[ppos].ang + z) % 360);
    }
    while (ppos > 1) {
      ppos >>= 1;
      a[ppos] = a[ppos << 1] + a[(ppos << 1) + 1];
    }
    printf("%.10f %.10f\n", a[1].x, a[1].y);
  }
  return 0;
}
