#include <bits/stdc++.h>
using namespace std;
const int MAX = 301000, KOR = 1000;
const double PI =
    3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
const double EPS = 1e-6;
struct ev {
  int st, ind;
  pair<double, double> prom;
};
bool operator<(const ev &a, const ev &b) { return a.ind < b.ind; }
vector<ev> E;
pair<double, double> poc[MAX], pros[MAX], p[MAX];
int n;
vector<int> Bit;
double cc[400], ss[400];
int rac;
double sumud;
pair<double, double> Rot(pair<double, double> toc, int an) {
  return pair<double, double>(toc.first * cc[an] - toc.second * ss[an],
                              toc.second * cc[an] + toc.first * ss[an]);
}
pair<double, double> Trans(pair<double, double> toc, pair<double, double> pom) {
  return pair<double, double>(toc.first + pom.first, toc.second + pom.second);
}
pair<double, double> Toc(int prosli, int ja, int an,
                         pair<double, double> polje[MAX]) {
  return Trans(p[prosli], Rot(pair<double, double>(
                                  polje[ja].first - polje[prosli].first,
                                  polje[ja].second - polje[prosli].second),
                              an));
}
inline double Sq(double x) { return x * x; }
double Dist(pair<double, double> a, pair<double, double> b) {
  return sqrt(Sq(a.first - b.first) + Sq(a.second - b.second));
}
void Ispis() {
  for (int j = 0; j < n; j++)
    fprintf(stderr, "%d   %lf %lf\n", j, p[j].first, p[j].second);
  fprintf(stderr, "\n\n");
}
void Event(ev tmp) {
  for (int i = 0; i < (int)Bit.size(); i++) pros[Bit[i]] = p[Bit[i]];
  for (int i = 0; i < (int)Bit.size(); i++) {
    if (Bit[i] > tmp.ind) {
      if (tmp.st == 1)
        p[Bit[i]] = Toc(tmp.ind, Bit[i], (int)(0.5 + tmp.prom.first), pros);
      else
        p[Bit[i]] = Trans(p[Bit[i]], tmp.prom);
    }
  }
  E.push_back(tmp);
  if (tmp.st == 2) sumud += tmp.prom.first + tmp.prom.second;
}
void Rebuild() {
  int zad = 0;
  int an = 0;
  sort(E.begin(), E.end());
  for (int i = 0; i < (int)Bit.size(); i++) pros[Bit[i]] = p[Bit[i]];
  for (int i = 0, j = 0, k = 0; i < n; i++) {
    for (; j < (int)E.size() && E[j].ind == i; j++)
      if (E[j].st == 1) an = ((int)(an + E[j].prom.first + 0.5)) % 360;
    if (k < (int)Bit.size() && Bit[k] == i) {
      zad = i;
      k++;
    } else {
      p[i] = Toc(zad, i, an, poc);
    }
  }
  memcpy(poc, p, sizeof p);
  E.clear();
}
int qst[MAX], qind[MAX], qval[MAX];
int main() {
  for (int i = 0; i < 360; i++) {
    cc[i] = cos(-PI / 180 * i);
    ss[i] = sin(-PI / 180 * i);
  }
  int m;
  scanf("%d%d", &n, &m);
  n++;
  for (int i = 0; i < n; i++) p[i] = pair<double, double>(i, 0);
  sumud = p[n - 1].first;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &qst[i], &qind[i], &qval[i]);
    qind[i]--;
    qst[i] = 3 - qst[i];
  }
  memcpy(poc, p, sizeof p);
  for (int i = 0; i < m; i++) {
    if (!(i % KOR)) {
      cerr << "i"
           << " = " << i << endl;
      Bit.clear();
      for (int j = i; j < i + KOR + 1; j++) {
        Bit.push_back(qind[j]);
        if (qst[j] == 2) Bit.push_back(qind[j] + 1);
      }
      Bit.push_back(0);
      Bit.push_back(n - 1);
      sort(Bit.begin(), Bit.end());
      Bit.resize(unique(Bit.begin(), Bit.end()) - Bit.begin());
      memcpy(pros, p, sizeof pros);
    }
    int st = qst[i], ind = qind[i];
    if (qst[i] == 1) {
      Event(ev{st, ind, pair<double, double>(qval[i], -1)});
    } else {
      pair<double, double> raz = pair<double, double>(
          p[ind + 1].first - p[ind].first, p[ind + 1].second - p[ind].second);
      double kut = atan2(raz.second, raz.first);
      pair<double, double> smjer = pair<double, double>(cos(kut), sin(kut));
      Event(ev{
          st, ind,
          pair<double, double>(smjer.first * qval[i], smjer.second * qval[i])});
    }
    if (E.size() == KOR) {
      Rebuild();
      E.clear();
      memcpy(pros, p, sizeof pros);
    }
    printf("%.10lf %.10lf\n", p[n - 1].first, p[n - 1].second);
  }
  return 0;
}
