#include <bits/stdc++.h>
using namespace std;
int n, m;
int len[1 << 19] = {}, rot[1 << 19] = {};
long double x[1 << 20], y[1 << 20];
int sta[1 << 20] = {};
const int off = 1 << 19;
long double c[360], s[360];
const long double PI = atan2((long double)0, (long double)-1);
void stMerge(int v, int a, int b, int ind) {
  int ang = sta[a];
  long double nx, ny;
  sta[v] = sta[a] + sta[b];
  if (sta[v] >= 360) sta[v] -= 360;
  if (ang == 0) {
    nx = x[b];
    ny = y[b];
  } else {
    nx = c[ang] * x[b] - s[ang] * y[b];
    ny = s[ang] * x[b] + c[ang] * y[b];
  }
  x[v] = x[a] + nx;
  y[v] = y[a] + ny;
}
void stBuild(int v, int L, int R) {
  if (L == R) {
    x[v] = len[L];
    y[v] = 0;
  } else {
    int mid = (L + R) >> 1;
    stBuild(2 * v, L, mid);
    stBuild(2 * v + 1, mid + 1, R);
    stMerge(v, 2 * v, 2 * v + 1, mid + 1);
  }
}
void stUpdate(int v, int L, int R, int pos) {
  if (L == R) {
    x[v] = len[L];
    y[v] = 0;
    sta[v] = rot[L];
    return;
  }
  int mid = (L + R) >> 1;
  if (pos <= mid)
    stUpdate(2 * v, L, mid, pos);
  else
    stUpdate(2 * v + 1, mid + 1, R, pos);
  stMerge(v, 2 * v, 2 * v + 1, mid + 1);
}
int main() {
  for (int i = 0; i < (int)(360); ++i) {
    c[i] = cos(-2 * i * PI / 360);
    s[i] = sin(-2 * i * PI / 360);
  }
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)(n); ++i) len[i] = 1, rot[i] = 0;
  stBuild(1, 0, off - 1);
  int finAng = 0;
  for (int i = 0; i < (int)(m); ++i) {
    int qx, qy, qz;
    scanf("%d%d%d", &qx, &qy, &qz), --qy;
    bool upd = true;
    if (qx == 1) {
      len[qy] += qz;
    } else if (qy) {
      --qy;
      rot[qy] += qz;
      if (rot[qy] >= 360) rot[qy] -= 360;
    } else {
      upd = false;
      finAng += qz;
      if (finAng >= 360) finAng -= 360;
    }
    if (upd) stUpdate(1, 0, off - 1, qy);
    long double nx, ny;
    if (finAng == 0) {
      nx = x[1];
      ny = y[1];
    } else {
      nx = c[finAng] * x[1] - s[finAng] * y[1];
      ny = s[finAng] * x[1] + c[finAng] * y[1];
    }
    printf("%.12f %.12f\n", (double)nx, (double)ny);
  }
  return 0;
}
