#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0;
  int f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
  return x * f;
}
void print(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
const int N = 400010;
const double pi = acos(-1);
struct point {
  double x, y;
  point(double _x = 0, double _y = 0) { x = _x, y = _y; }
  friend point operator+(point a, point b) {
    return point(a.x + b.x, a.y + b.y);
  }
  void rotate(double rad) {
    if (rad < 0) rad += pi;
    *this = point(x * cos(rad) - y * sin(rad), x * sin(rad) + y * cos(rad));
  }
  double lenth() { return sqrt(x * x + y * y); }
};
struct tree {
  point v;
  double rad;
  int l, r;
} t[N << 2];
void push_up(int x) {
  double len = t[x << 1 | 1].v.lenth();
  double th = atan2(t[x << 1 | 1].v.y, t[x << 1 | 1].v.x);
  t[x].v.x = t[x << 1].v.x + len * cos(t[x << 1].rad + th);
  t[x].v.y = t[x << 1].v.y + len * sin(t[x << 1].rad + th);
  t[x].rad = t[x << 1].rad + t[x << 1 | 1].rad;
}
void build(int x, int l, int r) {
  t[x].l = l, t[x].r = r;
  if (l == r) {
    t[x].v = point(1, 0);
    t[x].rad = 0;
    return;
  }
  int mid = l + r >> 1;
  build(x << 1, l, mid), build(x << 1 | 1, mid + 1, r);
  push_up(x);
}
void modify(int x, int p, double len, double rad) {
  if (t[x].l == t[x].r) {
    double l = t[x].v.lenth();
    double th = atan2(t[x].v.y, t[x].v.x);
    l += len;
    th += rad;
    t[x].v.x = l * cos(th);
    t[x].v.y = l * sin(th);
    t[x].rad = th;
    return;
  }
  int mid = t[x].l + t[x].r >> 1;
  if (p <= mid)
    modify(x << 1, p, len, rad);
  else
    modify(x << 1 | 1, p, len, rad);
  push_up(x);
}
int n, q;
int main() {
  n = read(), q = read();
  build(1, 1, n);
  while (q--) {
    int op = read(), x = read(), val = read();
    if (op & 1)
      modify(1, x, val, 0);
    else {
      val = 360 - val % 360;
      double t = (double)val / 180.0 * pi;
      modify(1, x, 0, t);
    }
    printf("%.10lf %.10lf\n", t[1].v.x, t[1].v.y);
  }
  return 0;
}
