#include <bits/stdc++.h>
using namespace std;
struct C {
  double x, y;
  C(double _x = 0, double _y = 0) {
    x = _x;
    y = _y;
  }
  double lensq() { return x * x + y * y; }
  double len() { return sqrt(x * x + y * y); }
};
C operator+(C a, C b) { return C(a.x + b.x, a.y + b.y); }
C operator-(C a, C b) { return C(a.x - b.x, a.y - b.y); }
C operator-(C a) { return C(-a.x, -a.y); }
C operator*(C a, C b) {
  return C(a.x * b.x - a.y * b.y, a.y * b.x + a.x * b.y);
}
C operator/(C a, C b) {
  double d = b.lensq();
  return C((a.x * b.x + a.y * b.y) / d, (a.y * b.x - a.x * b.y) / d);
}
const int N = 3e5 + 5;
const int T = (1 << 20) + 5;
C p[N];
int n;
C ta[T], tb[T];
int d;
void push(int v) {
  int l = v * 2, r = v * 2 + 1;
  ta[l] = ta[l] * tb[v];
  tb[l] = tb[l] * tb[v];
  ta[r] = ta[r] * tb[v];
  tb[r] = tb[r] * tb[v];
  tb[v] = 1;
  ta[l] = ta[l] + ta[v];
  ta[r] = ta[r] + ta[v];
  ta[v] = 0;
}
void add(int i, int j, C x, int l = 0, int r = d - 1, int v = 1) {
  if (i == l && j == r) {
    ta[v] = ta[v] + x;
    return;
  }
  push(v);
  int m = (l + r) >> 1;
  if (i <= m) add(i, min(m, j), x, l, m, v * 2);
  if (j > m) add(max(i, m + 1), j, x, m + 1, r, v * 2 + 1);
}
void mul(int i, int j, C x, int l = 0, int r = d - 1, int v = 1) {
  if (i == l && j == r) {
    ta[v] = ta[v] * x;
    tb[v] = tb[v] * x;
    return;
  }
  push(v);
  int m = (l + r) >> 1;
  if (i <= m) mul(i, min(m, j), x, l, m, v * 2);
  if (j > m) mul(max(i, m + 1), j, x, m + 1, r, v * 2 + 1);
}
C getval(int i, int l = 0, int r = d - 1, int v = 1) {
  if (l == r) {
    assert(i == l);
    return ta[v];
  }
  push(v);
  int m = (l + r) >> 1;
  if (i <= m)
    return getval(i, l, m, v * 2);
  else
    return getval(i, m + 1, r, v * 2 + 1);
}
void addall(int i, C x) {
  add(i, n - 1, x);
  return;
  while (i < n) {
    p[i] = p[i] + x;
    ++i;
  }
}
void mulall(int i, C x) {
  mul(i, n - 1, x);
  return;
  while (i < n) {
    p[i] = p[i] * x;
    ++i;
  }
}
C getme(int i) {
  return getval(i);
  return p[i];
}
int main() {
  int m;
  scanf("%d%d", &n, &m);
  ++n;
  for (int i = 0; i < n; ++i) p[i] = C(i, 0);
  for (d = 2; d < n; d <<= 1)
    ;
  for (int i = 0; i < n; ++i) {
    ta[i + d] = p[i];
  }
  for (int i = 1; i < d * 2; ++i) tb[i] = 1;
  double pi = acos(-1);
  while (m--) {
    int tp;
    scanf("%d", &tp);
    if (tp == 1) {
      int i, l;
      scanf("%d%d", &i, &l);
      C a = getme(i - 1);
      C b = getme(i);
      double ab = (a - b).len();
      addall(i, -a);
      addall(i, (b - a) * C(l / ab));
      addall(i, a);
    } else {
      int i, z;
      scanf("%d%d", &i, &z);
      double ang = z / 180.0 * pi;
      C r = C(cos(ang), -sin(ang));
      C a = getme(i - 1);
      addall(i, -a);
      mulall(i, r);
      addall(i, a);
    }
    C f = getme(n - 1);
    printf("%.10f %.10f\n", f.x, f.y);
  }
  return 0;
}
