#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
double mysin[360], mycos[360];
struct point {
  double x, y;
  friend point operator-(point a, point b) {
    point c;
    c.x = a.x - b.x;
    c.y = a.y - b.y;
    return c;
  }
  friend point operator*(point a, double b) {
    point c;
    c.x = a.x * b;
    c.y = a.y * b;
    return c;
  }
} p0, p1, p2;
void print(point a) { printf("%.10lf %.10lf\n", a.x, a.y); }
double dist(point a) { return sqrt(a.x * a.x + a.y * a.y); }
const int h = 20, M = 1 << h - 1;
struct matrix {
  double k1, k2, k3, k4, k5, k6;
  friend matrix operator*(matrix a, matrix b) {
    matrix c;
    c.k1 = a.k1 * b.k1 + a.k2 * b.k4;
    c.k2 = a.k1 * b.k2 + a.k2 * b.k5;
    c.k3 = a.k1 * b.k3 + a.k2 * b.k6 + a.k3;
    c.k4 = a.k4 * b.k1 + a.k5 * b.k4;
    c.k5 = a.k4 * b.k2 + a.k5 * b.k5;
    c.k6 = a.k4 * b.k3 + a.k5 * b.k6 + a.k6;
    return c;
  }
} ts, zkw[M + M], E;
void print(matrix a) {
  printf("%.10lf %.10lf %.10lf\n%.10lf %.10lf %.10lf\n", a.k1, a.k2, a.k3, a.k4,
         a.k5, a.k6);
}
matrix create(point p1, point p2, double L) {
  matrix temp;
  point p0 = (p2 - p1) * (L / dist(p2 - p1));
  temp.k1 = temp.k5 = 1;
  temp.k2 = temp.k4 = 0;
  temp.k3 = p0.x;
  temp.k6 = p0.y;
  return temp;
}
matrix create(point p0, int ang) {
  matrix temp;
  temp.k1 = mycos[ang];
  temp.k2 = mysin[ang];
  temp.k3 = -mycos[ang] * p0.x - mysin[ang] * p0.y + p0.x;
  temp.k4 = -mysin[ang];
  temp.k5 = mycos[ang];
  temp.k6 = mysin[ang] * p0.x - mycos[ang] * p0.y + p0.y;
  return temp;
}
void pushdown(int x) {
  if (x >= M) return;
  zkw[x + x] = zkw[x] * zkw[x + x];
  zkw[x + x + 1] = zkw[x] * zkw[x + x + 1];
  zkw[x] = E;
}
point query(int x) {
  x += M;
  for (int i = 1; i <= h; i++) {
    int xx = x >> h - i;
    pushdown(xx);
    if (xx != 1) pushdown(xx ^ 1);
  }
  point t;
  t.x = zkw[x].k3;
  t.y = zkw[x].k6;
  return t;
}
void change(int l, int r, matrix ts) {
  for (l += M - 1, r += M + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
    if (~l & 1) zkw[l ^ 1] = ts * zkw[l ^ 1];
    if (r & 1) zkw[r ^ 1] = ts * zkw[r ^ 1];
  }
}
void precompute() {
  for (int i = 1; i <= 359; i++) {
    mycos[i] = cos(double(i) / 180.0 * pi);
    mysin[i] = sin(double(i) / 180.0 * pi);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  precompute();
  E.k1 = E.k5 = 1;
  E.k2 = E.k3 = E.k4 = E.k6 = 0;
  p0.x = p0.y = 0;
  for (int i = 1; i < M; i++) zkw[i] = E;
  for (int i = M; i < M + M; i++) {
    zkw[i] = E;
    zkw[i].k3 = i - M - 1;
  }
  while (m--) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    if (x == 1) {
      p1 = query(y);
      p2 = query(y + 1);
      ts = create(p1, p2, z);
      query(y + 1 - 1);
      query(n + 1 + 1);
      change(y + 1, n + 1, ts);
    } else {
      p1 = query(y);
      ts = create(p1, z);
      query(y + 1 - 1);
      query(n + 1 + 1);
      change(y + 1, n + 1, ts);
    }
    print(query(n + 1));
  }
  return 0;
}
