#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool uin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const double pi = acosl(-1.0);
struct Mat {
  double a[3][3];
};
Mat rmat[360];
void Mul(const Mat& a, const Mat& b, Mat& c) {
  for (int i = 0; i < (int)(3); ++i)
    for (int j = 0; j < (int)(3); ++j) c.a[i][j] = 0;
  for (int i = 0; i < (int)(3); ++i)
    for (int j = 0; j < (int)(3); ++j)
      for (int k = 0; k < (int)(3); ++k) c.a[i][j] += a.a[i][k] * b.a[k][j];
}
const int N = 300000;
int n;
Mat rsq[1 << 21];
Mat shift;
int ee[N];
void up(int i) { Mul(rsq[i * 2], rsq[i * 2 + 1], rsq[i]); }
void solve() {
  shift.a[0][1] = shift.a[1][0] = shift.a[1][2] = shift.a[2][0] =
      shift.a[2][1] = 0;
  shift.a[0][0] = shift.a[1][1] = shift.a[2][2] = shift.a[0][2] = 1;
  for (int i = 0; i < (int)(360); ++i) {
    rmat[i].a[2][0] = 0;
    rmat[i].a[2][1] = 0;
    rmat[i].a[1][2] = 0;
    rmat[i].a[0][2] = 0;
    rmat[i].a[0][0] = rmat[i].a[1][1] = cosl(i * pi / 180.);
    rmat[i].a[0][1] = rmat[i].a[1][0] = sinl(i * pi / 180.);
    rmat[i].a[1][0] = -rmat[i].a[1][0];
    rmat[i].a[2][2] = 1;
  }
  int q;
  cin >> n >> q;
  n *= 2;
  int h = 1;
  while (h < n) h += h;
  for (int i = 0; i < (int)(h * 2); ++i) rsq[i] = rmat[0];
  for (int i = 0; i < (int)(n); ++i) {
    if (i & 1)
      rsq[i + h] = shift;
    else
      rsq[i + h] = rmat[0];
  }
  for (int i = (int)(h)-1; i >= 0; --i)
    if (i) {
      up(i);
    }
  for (int _ = 0; _ < (int)(q); ++_) {
    int t, i, z;
    cin >> t >> i >> z;
    i -= 1;
    if (t == 1) {
      rsq[i * 2 + 1 + h].a[0][2] += z;
      i = i * 2 + 1;
    } else {
      ee[i] += z;
      if (ee[i] >= 360) ee[i] -= 360;
      rsq[i * 2 + h] = rmat[ee[i]];
      i = i * 2;
    }
    i += h;
    while (i > 0) {
      i /= 2;
      up(i);
    }
    cout << rsq[1].a[0][2] << ' ' << rsq[1].a[1][2] << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed;
  cout.precision(15);
  cerr << fixed;
  cerr.precision(15);
  solve();
  return 0;
}
