#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
double precalSin[360];
double precalCos[360];
void fixAngle(int &x) {
  while (x < 0) x += 360;
  while (x >= 360) x -= 360;
}
struct point {
  double x, y;
  int angle, id;
  point(double x = 0, double y = 0, int angle = 0, int id = 0)
      : x(x), y(y), angle(angle), id(id) {}
  void rotate(point root, int angleR) {
    fixAngle(angleR);
    double tmpX =
        (x - root.x) * precalCos[angleR] - (y - root.y) * precalSin[angleR];
    double tmpY =
        (x - root.x) * precalSin[angleR] + (y - root.y) * precalCos[angleR];
    x = tmpX + root.x;
    y = tmpY + root.y;
    angle += angleR;
    fixAngle(angle);
  }
};
double distance(point a, point b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
struct query {
  int type, id;
  double x, y, len;
  int angle;
  query(int type = 0, int id = 0, double x = 0, double y = 0, double len = 0,
        int angle = 0)
      : type(type), id(id), x(x), y(y), len(len), angle(angle) {}
  void construct(int ttype, int iid, point xx, double vval) {
    if (ttype == 1) {
      type = 1;
      id = iid;
      x = xx.x;
      y = xx.y;
      len = vval;
      angle = xx.angle;
    } else {
      type = 2;
      id = iid;
      x = xx.x;
      y = xx.y;
      angle = (int)vval;
    }
  }
};
point a[300005];
int n, q;
vector<query> buffer;
double tmpLen[300005];
int tmpAngle[300005];
void rebuild() {
  for (int i = 1; i <= n; i++)
    tmpLen[i] = distance(a[i], a[i - 1]),
    tmpAngle[i] = a[i].angle - a[i - 1].angle, fixAngle(tmpAngle[i]);
  for (auto v : buffer) {
    if (v.type == 1) {
      tmpLen[v.id] += v.len;
    } else
      tmpAngle[v.id] += v.angle, fixAngle(tmpAngle[v.id]);
  }
  for (int i = 1; i <= n; i++) {
    a[i].x = a[i - 1].x + precalCos[a[i - 1].angle] * tmpLen[i];
    a[i].y = a[i - 1].y + precalSin[a[i - 1].angle] * tmpLen[i];
    a[i].angle = a[i - 1].angle;
    a[i].rotate(a[i - 1], tmpAngle[i]);
  }
  buffer.clear();
}
point getInformation(point cur) {
  for (auto v : buffer) {
    if (v.id > cur.id) continue;
    if (v.type == 1) {
      cur.x += precalCos[v.angle] * v.len;
      cur.y += precalSin[v.angle] * v.len;
    } else {
      point tmp;
      tmp.x = v.x;
      tmp.y = v.y;
      cur.rotate(tmp, v.angle);
    }
  }
  return cur;
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < 360; i++) {
    precalSin[i] = sin(pi * i / 180);
    precalCos[i] = cos(pi * i / 180);
  }
  for (int i = 1; i <= n; i++) a[i].x = i, a[i].id = i;
  while (q--) {
    int type, id;
    scanf("%d %d", &type, &id);
    if (type == 1) {
      int len;
      scanf("%d", &len);
      point cur = getInformation(a[id]);
      query tmp;
      tmp.construct(1, id, cur, len);
      buffer.push_back(tmp);
    } else {
      int angle;
      scanf("%d", &angle);
      angle = -angle;
      fixAngle(angle);
      point befCur = getInformation(a[id - 1]);
      query tmp;
      tmp.construct(2, id, befCur, angle);
      buffer.push_back(tmp);
    }
    point fin = getInformation(a[n]);
    printf("%.10f %.10f\n", fin.x, fin.y);
    if (buffer.size() == 550) rebuild();
  }
}
