#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:200000000")
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
const int NMAX = 310000;
double delta[NMAX * 4][3][3], md[NMAX * 4][3][3], add[3][3], result[3],
    mult_result[3][3], mult1_result[3], a0[3], a1[3];
bool upd[NMAX * 4];
void mult(double a[3][3], double b[3][3]) {
  for (int i = 0; i < (int)(3); i++)
    for (int j = 0; j < (int)(3); j++) {
      mult_result[i][j] = 0;
      for (int k = 0; k < (int)(3); k++) mult_result[i][j] += a[i][k] * b[k][j];
    }
}
void mult1(double a[3], double b[3][3]) {
  for (int i = 0; i < (int)(3); i++) {
    mult1_result[i] = 0;
    for (int k = 0; k < (int)(3); k++) mult1_result[i] += a[k] * b[k][i];
  }
}
void relax(int idx, int l, int r) {
  if (!upd[idx]) return;
  mult(md[idx], delta[idx]);
  memcpy(md[idx], mult_result, sizeof(md[idx]));
  upd[idx] = false;
  if (l != r) {
    mult(delta[idx << 1], delta[idx]);
    memcpy(delta[idx << 1], mult_result, sizeof(md[idx]));
    mult(delta[idx << 1 | 1], delta[idx]);
    memcpy(delta[idx << 1 | 1], mult_result, sizeof(md[idx]));
    upd[idx << 1] = upd[idx << 1 | 1] = true;
  }
  for (int i = 0; i < (int)(3); i++)
    for (int j = 0; j < (int)(3); j++) delta[idx][i][j] = i == j ? 1.0 : 0.0;
}
void update(int idx, int l, int r, int p) {
  relax(idx, l, r);
  if (l == p) {
    memcpy(delta[idx], add, sizeof(add));
    upd[idx] = true;
    relax(idx, l, r);
    return;
  }
  int mid = (l + r) >> 1;
  if (p <= mid) update(idx << 1, l, mid, p);
  update(idx << 1 | 1, mid + 1, r, max(p, mid + 1));
}
void get(int idx, int l, int r, int p) {
  relax(idx, l, r);
  if (l == r) {
    result[0] = l;
    result[1] = 0;
    result[2] = 1.0;
    mult1(result, md[idx]);
    memcpy(result, mult1_result, sizeof(mult1_result));
  } else {
    int mid = (l + r) >> 1;
    if (p <= mid)
      get(idx << 1, l, mid, p);
    else
      get(idx << 1 | 1, mid + 1, r, p);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (int)(NMAX * 4); i++)
    for (int j = 0; j < (int)(3); j++) md[i][j][j] = delta[i][j][j] = 1;
  for (int ii = 0; ii < (int)(m); ii++) {
    int tp, num, z;
    scanf("%d%d%d", &tp, &num, &z);
    num--;
    get(1, 0, n, num);
    memcpy(a0, result, sizeof(a0));
    if (tp == 1) {
      get(1, 0, n, num + 1);
      memcpy(a1, result, sizeof(a1));
      pair<double, double> v(a1[0] - a0[0], a1[1] - a0[1]);
      double len = sqrt(v.first * v.first + v.second * v.second);
      v.first /= len;
      v.second /= len;
      memset(add, 0, sizeof(add));
      add[0][0] = 1;
      add[2][0] = v.first * z;
      add[1][1] = 1;
      add[2][1] = v.second * z;
      add[2][2] = 1;
      update(1, 0, n, num + 1);
    } else {
      double ang = -z / 360.0 * 2 * PI;
      memset(add, 0, sizeof(add));
      add[0][0] = cos(ang);
      add[1][0] = -sin(ang);
      add[2][0] = -a0[0] * cos(ang) + a0[1] * sin(ang) + a0[0];
      add[0][1] = sin(ang);
      add[1][1] = cos(ang);
      add[2][1] = -a0[0] * sin(ang) - a0[1] * cos(ang) + a0[1];
      add[2][2] = 1;
      update(1, 0, n, num + 1);
    }
    get(1, 0, n, n);
    printf("%.10lf %.10lf\n", result[0], result[1]);
  }
  return 0;
}
