#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000 + 10;
const long double pi = acos(-1.0);
const long double eps = 1e-11;
int n, m;
long double sqr(long double x) { return x * x; }
struct point {
  long double x, y;
  point() {}
  point(long double _x, long double _y) {
    x = _x;
    y = _y;
  }
  point operator-(point o) { return point(x - o.x, y - o.y); }
  point operator+(point o) { return point(x + o.x, y + o.y); }
  point operator*(long double k) { return point(x * k, y * k); }
  long double len() { return sqrt(sqr(x) + sqr(y)); }
  void setlen(long double l) {
    long double k = l / len();
    x *= k, y *= k;
  }
  point rot(long double a) {
    return point(x * cos(a) - y * sin(a), x * sin(a) + y * cos(a));
  }
} B[maxn << 2], zero;
long double A[maxn << 2];
void trans(int cur, long double a, point move) {
  B[cur] = B[cur].rot(a);
  B[cur] = B[cur] + move;
  A[cur] += a;
}
void pull(int cur) {
  if (fabs(A[cur]) < eps && fabs(B[cur].x) < eps && fabs(B[cur].y) < eps)
    return;
  trans((cur << 1), A[cur], B[cur]);
  trans((cur << 1 | 1), A[cur], B[cur]);
  A[cur] = 0;
  B[cur] = point(0, 0);
}
void build(int cur, int l, int r) {
  if (l == r) {
    A[cur] = 0.;
    B[cur] = point((long double)l, 0.);
    return;
  }
  A[cur] = 0;
  B[cur] = point(0, 0);
  build((cur << 1), l, ((l + r) >> 1));
  build((cur << 1 | 1), ((l + r) >> 1) + 1, r);
}
void modify(int cur, int l, int r, int ql, int qr, long double a, point move) {
  if (ql <= l && r <= qr) {
    trans(cur, a, move);
    return;
  }
  pull(cur);
  if (ql <= ((l + r) >> 1))
    modify((cur << 1), l, ((l + r) >> 1), ql, qr, a, move);
  if (qr > ((l + r) >> 1))
    modify((cur << 1 | 1), ((l + r) >> 1) + 1, r, ql, qr, a, move);
}
point query(int cur, int l, int r, int pos) {
  if (l == r) return B[cur];
  pull(cur);
  if (pos <= ((l + r) >> 1))
    return query((cur << 1), l, ((l + r) >> 1), pos);
  else
    return query((cur << 1 | 1), ((l + r) >> 1) + 1, r, pos);
}
int main() {
  zero = point(0, 0);
  scanf("%d%d", &n, &m);
  build(1, 0, n);
  for (int i = 1; i <= m; i++) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      point p1 = query(1, 0, n, x);
      point p2 = query(1, 0, n, x - 1);
      point dir = query(1, 0, n, x) - query(1, 0, n, x - 1);
      dir.setlen(y);
      modify(1, 0, n, x, n, 0, dir);
    } else {
      point o = query(1, 0, n, x - 1);
      long double a = (360 - y) / (long double)360 * 2 * pi;
      point dir = point(-o.x * cos(a) + o.y * sin(a) + o.x,
                        -o.x * sin(a) - o.y * cos(a) + o.y);
      modify(1, 0, n, x, n, a, dir);
    }
    point ans = query(1, 0, n, n);
    printf("%.9lf %.9lf\n", (double)ans.x, (double)ans.y);
  }
  return 0;
}
