#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline void read(_T &_x) {
  int _t;
  bool _flag = false;
  while ((_t = getchar()) != '-' && (_t < '0' || _t > '9'))
    ;
  if (_t == '-') _flag = true, _t = getchar();
  _x = _t - '0';
  while ((_t = getchar()) >= '0' && _t <= '9') _x = _x * 10 + _t - '0';
  if (_flag) _x = -_x;
}
const int maxn = 300010;
struct Point {
  long double x, y;
  Point(long double a = 0, long double b = 0) : x(a), y(b) {}
  Point operator+(Point B) { return Point(x + B.x, y + B.y); }
};
struct Node {
  long double bas, arc, len;
  Node(int a = 0, int b = 0, int c = 0) : bas(a), arc(b), len(c) {}
  inline void add(int dir, int val) {
    if (dir == 1)
      len += val;
    else {
      arc -= val * M_PI / 180;
      bas -= val * M_PI / 180;
    }
  }
  inline Point calc(long double delta = 0) {
    return Point(len * cos(arc + delta), len * sin(arc + delta));
  }
} t[maxn << 2];
void print(int rt) {
  Point ret = t[rt].calc();
  cout << setprecision(10) << fixed << ret.x << ' ' << ret.y << '\n';
}
inline void pushup(int rt) {
  static Point res;
  res = t[rt << 1].calc() + t[rt << 1 | 1].calc(t[rt << 1].bas);
  t[rt].arc = atan2(res.y, res.x);
  t[rt].len = sqrt(res.x * res.x + res.y * res.y);
  t[rt].bas = t[rt << 1].bas + t[rt << 1 | 1].bas;
}
void build(int rt, int l, int r) {
  t[rt].arc = 0;
  t[rt].len = r - l + 1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid), build(rt << 1 | 1, mid + 1, r);
}
void change(int rt, int l, int r, int pos, int dir, int val) {
  if (l == r) {
    t[rt].add(dir, val);
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    change(rt << 1, l, mid, pos, dir, val);
  else
    change(rt << 1 | 1, mid + 1, r, pos, dir, val);
  pushup(rt);
}
int n, m;
int main() {
  read(n), read(m);
  build(1, 1, n);
  for (int i = 1, x, y, z; i <= m; ++i) {
    read(x), read(y), read(z);
    change(1, 1, n, y, x, z);
    print(1);
  }
  return 0;
}
