#include <bits/stdc++.h>
using namespace std;
int n, m;
const double pi = 4.0 * atan(1.0);
const int N = 333333;
double sx[N << 2], sy[N << 2], sa[N << 2];
void update(int v, int l, int r, int pos, int dx, double da) {
  if (l + 1 == r) {
    double R = sqrt(sx[v] * sx[v] + sy[v] * sy[v]);
    double A = atan2(sy[v], sx[v]);
    R += dx;
    A += da;
    sx[v] = R * cos(A);
    sy[v] = R * sin(A);
    sa[v] = A;
    return;
  }
  int mid = (l + r + 1) / 2;
  if (pos < mid)
    update(2 * v + 1, l, mid, pos, dx, da);
  else
    update(2 * v + 2, mid, r, pos, dx, da);
  double R =
      sqrt(sx[2 * v + 2] * sx[2 * v + 2] + sy[2 * v + 2] * sy[2 * v + 2]);
  double A = atan2(sy[2 * v + 2], sx[2 * v + 2]);
  sx[v] = sx[2 * v + 1] + R * cos(A + sa[2 * v + 1]);
  sy[v] = sy[2 * v + 1] + R * sin(A + sa[2 * v + 1]);
  sa[v] = sa[2 * v + 1] + sa[2 * v + 2];
}
int main(int argc, char *argv[]) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) update(0, 0, n, i, 1, 0);
  while (m--) {
    int tp, num, add;
    scanf("%d%d%d", &tp, &num, &add);
    if (tp == 1)
      update(0, 0, n, num - 1, add, 0);
    else
      update(0, 0, n, num - 1, 0, 2 * pi - add / 360.0 * 2.0 * pi);
    printf("%0.10lf %0.10lf\n", sx[0], sy[0]);
  }
  return 0;
}
