#include <bits/stdc++.h>
using namespace std;
double tsin[4 * 300010], tcos[4 * 300010], add[4 * 300010];
void push(int v, int vl, int vr) {
  if (vl != vr) {
    add[2 * v + 1] += add[v];
    add[2 * v + 2] += add[v];
  }
  double asin = tsin[v], acos = tcos[v];
  double bsin = sin(add[v]), bcos = cos(add[v]);
  tsin[v] = bcos * asin + bsin * acos;
  tcos[v] = bcos * acos - bsin * asin;
  add[v] = 0;
}
void build(int v, int vl, int vr) {
  if (vl == vr) {
    tsin[v] = 0;
    tcos[v] = 1;
    return;
  }
  int vm = vl + (vr - vl) / 2;
  build(2 * v + 1, vl, vm);
  build(2 * v + 2, vm + 1, vr);
  tsin[v] = tsin[2 * v + 1] + tsin[2 * v + 2];
  tcos[v] = tcos[2 * v + 1] + tcos[2 * v + 2];
}
pair<double, double> query(int v, int vl, int vr, int l, int r) {
  push(v, vl, vr);
  if (r < vl || vr < l) return make_pair(0, 0);
  if (l <= vl && vr <= r) return make_pair(tsin[v], tcos[v]);
  int vm = vl + (vr - vl) / 2;
  pair<double, double> ql = query(2 * v + 1, vl, vm, l, r);
  pair<double, double> qr = query(2 * v + 2, vm + 1, vr, l, r);
  return make_pair(ql.first + qr.first, ql.second + qr.second);
}
void modify(int v, int vl, int vr, int l, int r, double val) {
  push(v, vl, vr);
  if (r < vl || vr < l) return;
  if (l <= vl && vr <= r) {
    add[v] += val;
    push(v, vl, vr);
    return;
  }
  int vm = vl + (vr - vl) / 2;
  modify(2 * v + 1, vl, vm, l, r, val);
  modify(2 * v + 2, vm + 1, vr, l, r, val);
  tsin[v] = tsin[2 * v + 1] + tsin[2 * v + 2];
  tcos[v] = tcos[2 * v + 1] + tcos[2 * v + 2];
}
void modify1(int v, int vl, int vr, int pos, double val) {
  push(v, vl, vr);
  if (pos < vl || vr < pos) return;
  if (pos <= vl && vr <= pos) {
    tsin[v] *= val;
    tcos[v] *= val;
    return;
  }
  int vm = vl + (vr - vl) / 2;
  modify1(2 * v + 1, vl, vm, pos, val);
  modify1(2 * v + 2, vm + 1, vr, pos, val);
  tsin[v] = tsin[2 * v + 1] + tsin[2 * v + 2];
  tcos[v] = tcos[2 * v + 1] + tcos[2 * v + 2];
}
int n, m, l[300010];
int main() {
  scanf("%d%d", &n, &m);
  fill(l, l + n, 1);
  build(0, 0, n - 1);
  for (int i = 0; i < m; i++) {
    int type, seg;
    double arg;
    scanf("%d%d%lf", &type, &seg, &arg);
    if (type == 1) {
      double oldLen = l[seg - 1], newLen = oldLen + arg,
             delta = newLen / oldLen;
      l[seg - 1] = newLen;
      modify1(0, 0, n - 1, seg - 1, delta);
    } else {
      arg = arg / 180.0 * acos(-1.0);
      modify(0, 0, n - 1, seg - 1, n - 1, arg);
    }
    pair<double, double> q = query(0, 0, n - 1, 0, n - 1);
    printf("%.10lf %.10lf\n", q.second, -q.first);
  }
}
