#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
const double pi = 3.141592653589793238462643383279502884197169399;
int n, q;
double x[N], y[N];
int z[N], a[N];
inline void pushup(int i) {
  x[i] = x[(i << 1)] + x[(i << 1 | 1)] * cos(z[(i << 1)] * pi / 180) +
         y[(i << 1 | 1)] * sin(z[(i << 1)] * pi / 180);
  y[i] = y[(i << 1)] - x[(i << 1 | 1)] * sin(z[(i << 1)] * pi / 180) +
         y[(i << 1 | 1)] * cos(z[(i << 1)] * pi / 180);
  z[i] = (z[(i << 1)] + z[(i << 1 | 1)]) % 360;
  a[i] = a[(i << 1)] + a[(i << 1 | 1)];
}
void build(int i, int L, int R) {
  if (L == R) {
    a[i] = 1, z[i] = 0, x[i] = 1;
    y[i] = 0;
    return;
  }
  build((i << 1), L, ((L + R) >> 1));
  build((i << 1 | 1), ((L + R) >> 1) + 1, R);
  pushup(i);
}
void update1(int i, int L, int R, int pos, int val) {
  if (L == R) {
    a[i] += val;
    x[i] = a[i] * cos(z[i] * pi / 180);
    y[i] = a[i] * -sin(z[i] * pi / 180);
    return;
  }
  if (pos <= ((L + R) >> 1))
    update1((i << 1), L, ((L + R) >> 1), pos, val);
  else
    update1((i << 1 | 1), ((L + R) >> 1) + 1, R, pos, val);
  pushup(i);
}
void update2(int i, int L, int R, int pos, int val) {
  if (L == R) {
    (z[i] += val) %= 360;
    x[i] = a[i] * cos(z[i] * pi / 180);
    y[i] = a[i] * -sin(z[i] * pi / 180);
    return;
  }
  if (pos <= ((L + R) >> 1))
    update2((i << 1), L, ((L + R) >> 1), pos, val);
  else
    update2((i << 1 | 1), ((L + R) >> 1) + 1, R, pos, val);
  pushup(i);
}
int main() {
  scanf("%d%d", &n, &q);
  build(1, 1, n);
  while (q--) {
    int op, i, j;
    scanf("%d%d%d", &op, &i, &j);
    if (op == 1)
      update1(1, 1, n, i, j);
    else
      update2(1, 1, n, i, j);
    printf("%.12f %.12f\n", x[1], y[1]);
  }
  return 0;
}
