#include <bits/stdc++.h>
const double PI = acos(-1);
struct pnt {
  double x, y;
  pnt(double x = 0, double y = 0) : x(x), y(y) {}
  pnt operator+(const pnt &p) const { return pnt(x + p.x, y + p.y); }
  pnt operator*(double p) const { return pnt(x * p, y * p); }
  pnt operator*(const pnt &p) const {
    return pnt(x * p.x - y * p.y, x * p.y + y * p.x);
  }
} p[2000005];
int len[2000005], ang[2000005];
int main() {
  int n, q, m;
  scanf("%d %d", &n, &q);
  for (m = 1; m <= n; m <<= 1)
    ;
  for (int i = m; i < m + n; i++) {
    len[i] = 1;
    p[i] = pnt(1, 0);
  }
  for (int i = m - 1; i; i--) p[i] = p[i << 1] + p[i << 1 | 1];
  while (q--) {
    int bf, i, v;
    scanf("%d %d %d", &bf, &i, &v);
    i += m - 1;
    if (bf == 1)
      len[i] += v;
    else
      ang[i] = (ang[i] + 360 - v) % 360;
    p[i] = pnt(cos(ang[i] * PI / 180), sin(ang[i] * PI / 180)) * len[i];
    while (i >>= 1) {
      double alpha = ang[i << 1] * PI / 180;
      p[i] = p[i << 1] + p[i << 1 | 1] * pnt(cos(alpha), sin(alpha));
      ang[i] = (ang[i << 1] + ang[i << 1 | 1]) % 360;
    }
    printf("%.10lf %.10lf\n", p[1].x, p[1].y);
  }
}
