#include <bits/stdc++.h>
using namespace std;
const long double PI = acos((long double)-1.0);
const long double EPS = (long double)1e-18;
struct Node {
  int l, r;
  long double x, y;
  int lazy;
  Node *left, *right;
  Node(int l, int r)
      : l(l), r(r), x(r - l + 1), y(0), lazy(0), left(NULL), right(NULL) {}
  void gather() {
    x = left->x + right->x;
    y = left->y + right->y;
  }
  void pushDown() {
    if (lazy) {
      long double radian = lazy * PI / 180;
      long double _cos = cos(radian);
      long double _sin = sin(radian);
      long double newX = x * _cos - y * _sin;
      long double newY = x * _sin + y * _cos;
      x = newX;
      y = newY;
      if (l < r) {
        left->lazy += lazy;
        right->lazy += lazy;
      }
      lazy = 0;
    }
  }
  void incLength(int i, int length) {
    pushDown();
    if (r < i || i < l) return;
    if (l == r) {
      long double curLength = sqrt(x * x + y * y);
      long double ratio = (curLength + length) / curLength;
      x = x * ratio;
      y = y * ratio;
      return;
    }
    left->incLength(i, length);
    right->incLength(i, length);
    gather();
  }
  void rotate(int i, int j, int degree) {
    pushDown();
    if (r < i || j < l) return;
    if (i <= l && r <= j) {
      lazy += degree;
      pushDown();
      return;
    }
    left->rotate(i, j, degree);
    right->rotate(i, j, degree);
    gather();
  }
};
Node *build(int l, int r) {
  Node *x = new Node(l, r);
  if (l == r) return x;
  x->left = build(l, l + r >> 1);
  x->right = build((l + r >> 1) + 1, r);
  return x;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(9) << fixed;
  int n, m;
  cin >> n >> m;
  Node *root = build(1, n);
  while (m--) {
    int cmd, x, y;
    cin >> cmd >> x >> y;
    if (cmd == 1)
      root->incLength(x, y);
    else
      root->rotate(x, n, 360 - y);
    cout << root->x << ' ' << root->y << '\n';
  }
  return 0;
}
