#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1 << 19;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long double MUL = -acosl(-1.0) / 180.0;
int n, m;
pair<long double, long double> t[2 * MaxN];
long double angles[2 * MaxN];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    t[i + MaxN] = make_pair(1, 0);
  }
  for (int i = MaxN - 1; i > 0; --i) {
    long double x = t[i + i + 1].first, y = t[i + i + 1].second;
    long double ang = angles[i + i];
    long double cang = cosl(ang), sang = sinl(ang);
    long double nx = x * cang - y * sang;
    long double ny = y * cang + x * sang;
    t[i].first = t[i + i].first + nx;
    t[i].second = t[i + i].second + ny;
    angles[i] = angles[i + i] + angles[i + i + 1];
  }
  for (int it = 0; it < m; ++it) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    if (x == 1) {
      y += MaxN;
      t[y].first += z;
    } else {
      y += MaxN - 1;
      angles[y] += MUL * z;
    }
    for (register int i = y >> 1; i > 0; i >>= 1) {
      long double x = t[i + i + 1].first, y = t[i + i + 1].second;
      long double ang = angles[i + i];
      long double cang = cosl(ang), sang = sinl(ang);
      long double nx = x * cang - y * sang;
      long double ny = y * cang + x * sang;
      t[i].first = t[i + i].first + nx;
      t[i].second = t[i + i].second + ny;
      angles[i] = angles[i + i] + angles[i + i + 1];
    }
    printf("%.10lf %.10lf\n", (double)t[1].first, (double)t[1].second);
  }
  return 0;
}
