#include <bits/stdc++.h>
using namespace std;
long double jd[1100000], x[1100000], y[1100000];
long double pi =
    3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647;
int n, m;
bool b;
long double qq;
void cty(int k, int l, int r, int o) {
  if (l > o || r < o) return;
  if (l == r) {
    if (b)
      jd[k] += qq;
    else
      x[k] += qq;
    return;
  }
  int m = (l + r) >> 1, e = k << 1;
  cty(e, l, m, o), cty(e ^ 1, m + 1, r, o);
  jd[k] = jd[e] + jd[e ^ 1];
  x[k] = x[e] + x[e ^ 1] * cos(jd[e]) - y[e ^ 1] * sin(jd[e]);
  y[k] = y[e] + x[e ^ 1] * sin(jd[e]) + y[e ^ 1] * cos(jd[e]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) x[i + 524288] = 1.0;
  for (int i = 524287; i; i--) {
    int e = i << 1;
    jd[i] = jd[e] + jd[e ^ 1];
    x[i] = x[e] + x[e ^ 1] * cos(jd[e]) - y[e ^ 1] * sin(jd[e]);
    y[i] = y[e] + x[e ^ 1] * sin(jd[e]) + y[e ^ 1] * cos(jd[e]);
  }
  while (m--) {
    int q, w, Z;
    long double z;
    scanf("%d%d%d", &q, &w, &Z);
    z = Z;
    qq = (q == 1) ? z : -z / 180.0 * pi;
    b = q - 1;
    if (b) w--;
    cty(1, 0, 524287, w);
    printf("%.20lf %.20lf\n", (double)x[1], (double)y[1]);
  }
  return 0;
}
