#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long Inf = 1e10;
const int P = 1e9 + 7;
const int N = 300005;
inline int IN() {
  int x = 0;
  int ch = 0, f = 0;
  for (ch = getchar(); ch != -1 && (ch < 48 || ch > 57); ch = getchar())
    f = (ch == '-');
  for (; ch >= 48 && ch <= 57; ch = getchar())
    x = (x << 1) + (x << 3) + ch - '0';
  return f ? (-x) : x;
}
int Pow(int x, int y, int p) {
  int a = 1;
  for (; y; y >>= 1, x = (long long)x * x % p)
    if (y & 1) a = (long long)a * x % p;
  return a;
}
int n, m;
struct mat {
  double v[5][5];
} t[N * 4];
mat operator*(const mat &a, const mat &b) {
  mat c;
  memset(c.v, 0, sizeof c.v);
  for (int i = (int)(1); i <= (int)(3); i++)
    for (int j = (int)(1); j <= (int)(3); j++) {
      c.v[i][j] = 0;
      for (int k = (int)(1); k <= (int)(3); k++)
        c.v[i][j] += a.v[i][k] * b.v[k][j];
    }
  return c;
}
void B(int x, int L, int R) {
  for (int i = (int)(1); i <= (int)(3); i++)
    for (int j = (int)(1); j <= (int)(3); j++) t[x].v[i][j] = (i == j);
  if (L == R) return;
  B(x * 2, L, ((L + R) >> 1));
  B(x * 2 + 1, ((L + R) >> 1) + 1, R);
}
void sep(int x) {
  t[x * 2] = t[x * 2] * t[x];
  t[x * 2 + 1] = t[x * 2 + 1] * t[x];
  for (int i = (int)(1); i <= (int)(3); i++)
    for (int j = (int)(1); j <= (int)(3); j++) t[x].v[i][j] = (i == j);
}
mat mul, tmp;
void M(int x, int L, int R, int ql, int qr) {
  if (ql <= L && R <= qr) return (void)(t[x] = t[x] * mul);
  sep(x);
  if (ql <= ((L + R) >> 1)) M(x * 2, L, ((L + R) >> 1), ql, qr);
  if (((L + R) >> 1) < qr) M(x * 2 + 1, ((L + R) >> 1) + 1, R, ql, qr);
}
double ax, ay;
void Q(int x, int L, int R, int v) {
  if (v == 0) {
    ax = ay = 0;
    return;
  }
  if (L == R) {
    double ox = L, oy = 0;
    ax = ox * t[x].v[1][1] + oy * t[x].v[2][1] + t[x].v[3][1];
    ay = ox * t[x].v[1][2] + oy * t[x].v[2][2] + t[x].v[3][2];
    return;
  }
  sep(x);
  if (v <= ((L + R) >> 1))
    Q(x * 2, L, ((L + R) >> 1), v);
  else
    Q(x * 2 + 1, ((L + R) >> 1) + 1, R, v);
}
double pi = acos(-1);
int main() {
  scanf("%d%d", &n, &m);
  B(1, 1, n);
  while (m--) {
    int op = IN(), x = IN(), y = IN();
    for (int i = (int)(1); i <= (int)(3); i++)
      for (int j = (int)(1); j <= (int)(3); j++) mul.v[i][j] = 0;
    if (op == 1) {
      double tx, ty, mx, my;
      Q(1, 1, n, x - 1);
      tx = ax, ty = ay;
      Q(1, 1, n, x);
      mx = ax, my = ay;
      double theta = atan2(my - ty, mx - tx);
      for (int i = (int)(1); i <= (int)(3); i++) mul.v[i][i] = 1;
      mul.v[3][1] = cos(theta) * y;
      mul.v[3][2] = sin(theta) * y;
    } else {
      Q(1, 1, n, x - 1);
      for (int i = (int)(1); i <= (int)(3); i++)
        for (int j = (int)(1); j <= (int)(3); j++) tmp.v[i][j] = 0;
      for (int i = (int)(1); i <= (int)(3); i++) tmp.v[i][i] = 1;
      tmp.v[3][1] = -ax;
      tmp.v[3][2] = -ay;
      mul = tmp;
      for (int i = (int)(1); i <= (int)(3); i++)
        for (int j = (int)(1); j <= (int)(3); j++) tmp.v[i][j] = 0;
      double theta = -y / 180. * pi;
      tmp.v[1][1] = tmp.v[2][2] = cos(theta);
      tmp.v[1][2] = tmp.v[2][1] = sin(theta);
      tmp.v[2][1] = -tmp.v[2][1];
      tmp.v[3][3] = 1;
      mul = mul * tmp;
      for (int i = (int)(1); i <= (int)(3); i++)
        for (int j = (int)(1); j <= (int)(3); j++) tmp.v[i][j] = 0;
      for (int i = (int)(1); i <= (int)(3); i++) tmp.v[i][i] = 1;
      tmp.v[3][1] = ax;
      tmp.v[3][2] = ay;
      mul = mul * tmp;
    }
    M(1, 1, n, x, n);
    Q(1, 1, n, n);
    printf("%.10lf %.10lf\n", ax, ay);
  }
  return 0;
}
