#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
const int N = 3e5 + 5;
int n, m;
struct node {
  long double x, y, theta;
  node() : x(1.0), y(0.0), theta(0.0) {}
  node(long double _x, long double _y, long double _theta)
      : x(_x), y(_y), theta(_theta) {}
};
node merge(node a, node b) {
  a.x = a.x + b.x * cos(a.theta) - b.y * sin(a.theta);
  a.y = a.y + b.x * sin(a.theta) + b.y * cos(a.theta);
  a.theta += b.theta;
  return a;
}
long double dist(long double x, long double y) { return sqrtl(x * x + y * y); }
long double radian(long double theta) { return theta * PI / 180.0; }
node st[4 * N];
void pull(int idx) {
  int lc = idx << 1, rc = lc | 1;
  st[idx] = merge(st[lc], st[rc]);
}
void build(int idx, int l, int r) {
  if (l == r) {
    st[idx] = node();
    return;
  }
  int mid = (l + r) >> 1, lc = idx << 1, rc = lc | 1;
  build(lc, l, mid);
  build(rc, mid + 1, r);
  pull(idx);
}
void updateT(int idx, int l, int r, int x, long double val) {
  if (r < x || x < l) return;
  if (l == r) {
    long double d = dist(st[idx].x, st[idx].y);
    long double mul = (d + val) / d;
    st[idx].x *= mul, st[idx].y *= mul;
    return;
  }
  int mid = (l + r) >> 1, lc = idx << 1, rc = lc | 1;
  updateT(lc, l, mid, x, val);
  updateT(rc, mid + 1, r, x, val);
  pull(idx);
}
void updateR(int idx, int l, int r, int x, long double val) {
  if (r < x || x < l) return;
  if (l == r) {
    long double d = dist(st[idx].x, st[idx].y);
    long double theta = atan2(st[idx].y, st[idx].x) - radian(val);
    st[idx].x = d * cos(theta);
    st[idx].y = d * sin(theta);
    st[idx].theta = theta;
    return;
  }
  int mid = (l + r) >> 1, lc = idx << 1, rc = lc | 1;
  updateR(lc, l, mid, x, val);
  updateR(rc, mid + 1, r, x, val);
  pull(idx);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  build(1, 1, n);
  while (m--) {
    int op, id, x;
    cin >> op >> id >> x;
    if (op == 1)
      updateT(1, 1, n, id, x);
    else
      updateR(1, 1, n, id, x);
    cout << fixed << setprecision(4) << st[1].x << ' ' << st[1].y << '\n';
  }
  return 0;
}
