#include <bits/stdc++.h>
using namespace std;
const double Pi = 3.1415926535897932384626433832795;
const int max_n = 3e5 + 5;
struct Node {
  double sx, sy, lazy;
  inline void merge(const Node &a, const Node &b) {
    sx = a.sx + b.sx, sy = a.sy + b.sy;
  }
  inline void update(double ang) {
    lazy += ang;
    double Cos = cos(ang), Sin = sin(ang);
    double x = sx * Cos + sy * Sin, y = sy * Cos - sx * Sin;
    sx = x, sy = y;
  }
} tree[max_n << 2];
inline void push_down(int p) {
  tree[p << 1].update(tree[p].lazy);
  tree[p << 1 | 1].update(tree[p].lazy);
  tree[p].lazy = 0;
}
void build(int p, int l, int r) {
  if (l == r) {
    tree[p].sx = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  tree[p].merge(tree[p << 1], tree[p << 1 | 1]);
}
double res_x, res_y;
void query(int p, int l, int r, int k) {
  if (l == r) {
    res_x = tree[p].sx, res_y = tree[p].sy;
    return;
  }
  if (tree[p].lazy) push_down(p);
  int mid = (l + r) >> 1;
  if (k <= mid)
    query(p << 1, l, mid, k);
  else
    query(p << 1 | 1, mid + 1, r, k);
}
void modify(int p, int l, int r, int k, double dx, double dy) {
  tree[p].sx += dx, tree[p].sy += dy;
  if (l < r) {
    int mid = (l + r) >> 1;
    if (k <= mid)
      modify(p << 1, l, mid, k, dx, dy);
    else
      modify(p << 1 | 1, mid + 1, r, k, dx, dy);
  }
}
void rotate(int p, int l, int r, int a, int b, double ang) {
  if (a <= l && r <= b) {
    tree[p].update(ang);
    return;
  }
  if (tree[p].lazy) push_down(p);
  int mid = (l + r) >> 1;
  if (a <= mid) rotate(p << 1, l, mid, a, b, ang);
  if (b > mid) rotate(p << 1 | 1, mid + 1, r, a, b, ang);
  tree[p].merge(tree[p << 1], tree[p << 1 | 1]);
}
int main() {
  int n, m;
  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) {
      query(1, 1, n, y);
      double d = sqrt(res_x * res_x + res_y * res_y);
      modify(1, 1, n, y, z * res_x / d, z * res_y / d);
    } else {
      double ang = z * Pi / 180;
      rotate(1, 1, n, y, n, ang);
    }
    printf("%.10lf %.10lf\n", tree[1].sx, tree[1].sy);
  }
  return 0;
}
