#include <bits/stdc++.h>
using namespace std;
const int inft = 1000000009;
const int mod = 1000000007;
const double PI = acos(-1);
struct mat4 {
  double m[4][4];
};
struct vec4 {
  double v[4];
};
mat4 operator*(const mat4 &a, const mat4 &b) {
  mat4 ret = {0};
  for (int i = 0; i < (4); ++i)
    for (int j = 0; j < (4); ++j)
      for (int k = 0; k < (4); ++k) ret.m[i][j] += a.m[i][k] * b.m[k][j];
  return ret;
}
vec4 operator*(const mat4 &a, const vec4 &b) {
  vec4 ret = {0};
  for (int i = 0; i < (4); ++i)
    for (int j = 0; j < (4); ++j) ret.v[i] += a.m[i][j] * b.v[j];
  return ret;
}
void init(mat4 &m) {
  for (int j = 0; j < (4); ++j) m.m[j][j] = 1;
}
void init(vec4 &v) { v.v[2] = 1; }
void init_trans(mat4 &m, double d) {
  init(m);
  m.m[0][2] = m.m[1][3] = d;
}
void init_rot(mat4 &m, double a) {
  init(m);
  m.m[2][2] = cos(a);
  m.m[2][3] = sin(a);
  m.m[3][2] = -sin(a);
  m.m[3][3] = cos(a);
}
const int MAXN = 1024 * 512;
mat4 drz[2 * MAXN];
void napraw(int u) { drz[u] = drz[2 * u + 1] * drz[2 * u]; }
vec4 compute(int u) {
  int a = MAXN, b = MAXN + u - 1;
  mat4 ma = {0}, mb = {0};
  init(ma);
  init(mb);
  while (a <= b) {
    if (a % 2 == 1) ma = drz[a] * ma;
    if (b % 2 == 0) mb = mb * drz[b];
    a = (a + 1) / 2;
    b = (b - 1) / 2;
  }
  vec4 v = {0};
  init(v);
  return mb * (ma * v);
}
void wypisz(const vec4 &v) {
  for (int i = 0; i < (2); ++i) printf("%.9lf ", v.v[i]);
  puts("");
}
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (MAXN); ++i) init_trans(drz[i + MAXN], 1);
  for (int i = MAXN - 1; i > 0; i--) napraw(i);
  for (int q = 0; q < (m); ++q) {
    int first, second, z;
    scanf("%d%d%d", &first, &second, &z);
    second--;
    second += MAXN;
    if (first == 1) {
      mat4 nop = {0};
      init_trans(nop, z);
      drz[second] = nop * drz[second];
    } else {
      mat4 nop = {0};
      init_rot(nop, PI * z / 180);
      drz[second] = drz[second] * nop;
    }
    while (second /= 2) napraw(second);
    wypisz(compute(n));
  }
}
int main() {
  int te = 1;
  for (int ti = 0; ti < (te); ++ti) solve();
  return 0;
}
