#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 9;
const double pi = acos(-1.0);
struct Point {
  double x, y;
  double lazy;
  void rotate(double a) {
    double xx = x, yy = y;
    x = xx * cos(a) - yy * sin(a);
    y = yy * cos(a) + xx * sin(a);
  }
  Point operator+(const Point& b) const { return (Point){x + b.x, y + b.y}; }
} tr[N << 2];
int n, m;
double f(int x) { return -pi * x / 180; }
void build(int o, int l, int r) {
  if (l == r) {
    tr[o].x = 1;
    tr[o].y = 0;
    tr[o].lazy = 0;
    return;
  }
  int m = (l + r) >> 1;
  build(o << 1, l, m);
  build(o << 1 | 1, m + 1, r);
  tr[o] = tr[o << 1] + tr[o << 1 | 1];
}
void push_down(int o) {
  if (tr[o].lazy == 0) return;
  tr[o << 1].rotate(f(tr[o].lazy));
  tr[o << 1 | 1].rotate(f(tr[o].lazy));
  tr[o << 1].lazy += tr[o].lazy;
  tr[o << 1 | 1].lazy += tr[o].lazy;
  tr[o].lazy = 0;
}
void change(int o, int l, int r, int L, int R, int len, int a) {
  if (L <= l && r <= R) {
    if (len) {
      double t = sqrt(tr[o].x * tr[o].x + tr[o].y * tr[o].y);
      tr[o].x = tr[o].x * (t + len) / t;
      tr[o].y = tr[o].y * (t + len) / t;
    } else {
      tr[o].lazy += a;
      tr[o].rotate(f(a));
    }
    return;
  }
  push_down(o);
  int m = (l + r) >> 1;
  if (L <= m) change(o << 1, l, m, L, R, len, a);
  if (R > m) change(o << 1 | 1, m + 1, r, L, R, len, a);
  tr[o] = tr[o << 1] + tr[o << 1 | 1];
}
int main() {
  scanf("%d %d", &n, &m);
  build(1, 1, n);
  for (int i = 1; i <= m; ++i) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    if (x == 1)
      change(1, 1, n, y, y, z, 0);
    else
      change(1, 1, n, y, n, 0, z);
    printf("%.10f %.10f\n", tr[1].x, tr[1].y);
  }
  return 0;
}
