#include <bits/stdc++.h>
using namespace std;
int n;
int m;
int q;
int len[333333], ang[333333];
long double x[666], y[666];
int Ang[666];
long double Sin[360], Cos[360];
void add(int &x, int y) {
  x += y;
  while (x >= 360) x -= 360;
}
void solve1(int i, int L) {
  int j = (i + m - 1) / m;
  len[i] += L;
  x[j] += L * Cos[ang[i]];
  y[j] += L * Sin[ang[i]];
}
void solve2(int i, int z) {
  int j = (i + m - 1) / m;
  for (int jj = j + 1; jj <= m; jj++) add(Ang[jj], z);
  for (; i <= j * m; i++) add(ang[i], z);
  x[j] = 0, y[j] = 0;
  for (i = (j - 1) * m + 1; i <= j * m; i++) {
    int a = ang[i];
    x[j] += len[i] * Cos[a];
    y[j] += len[i] * Sin[a];
  }
}
void solve() {
  long double X = 0, Y = 0;
  for (int i = 1; i <= m; i++) {
    int a = Ang[i];
    X += x[i] * Cos[a] - y[i] * Sin[a];
    Y += x[i] * Sin[a] + y[i] * Cos[a];
  }
  printf("%.10lf %.10lf\n", (double)X, double(Y));
}
int main() {
  double pi = acos(-1);
  for (int x = 0; x < 360; x++) {
    Sin[x] = sin(-x * pi / 180);
    Cos[x] = cos(-x * pi / 180);
  }
  scanf("%d %d", &n, &q);
  m = sqrt(n) + 1;
  for (int i = 1; i <= m * m; i++) {
    ang[i] = 0;
    len[i] = !!(i <= n);
    x[(i + m - 1) / m] += len[i];
  }
  n = m * m;
  while (q--) {
    int type, id, L;
    scanf("%d %d %d", &type, &id, &L);
    if (type == 1) {
      solve1(id, L);
    } else {
      solve2(id, L);
    }
    solve();
  }
  return 0;
}
