#include #include int main() { int n, q; scanf("%d %d", &n, &q); int i, j, k; int t[100005], ind[100005]; double nx[100005]; for (i = 0; i < q; i++) { scanf("%d %d", &t[i], &ind[i]); if (t[i] < 2) { scanf("%lf", &nx[i]); ind[i]--; } } double length[100005], theta[100005], st[100005]; for (i = 0; i < n; i++) { length[i] = 1.0; theta[i] = 0.0; st[i] = 0.0; } int sq = 0; while (sq * sq < n) sq++; double x[100005], y[100005]; x[0] = y[0] = 0.0; for (i = 0; i < n; i++) { x[i + 1] = x[i] + length[i]; y[i + 1] = 0; } double xx, yy, ds, r, s, dx, dy, dl; for (i = 0; i < q; i++) { if (t[i] == 0) { ds = nx[i] * acos(-1) / 180.0 - theta[ind[i]]; theta[ind[i]] = nx[i] * acos(-1) / 180.0; if (ind[i] > 0) st[ind[i]] = st[ind[i] - 1] + theta[ind[i]]; else st[0] = theta[0]; j = 0; while (j + sq <= ind[i]) j += sq; k = j + sq; for (; j <= k; j++) { x[j + 1] = x[j] + length[j] * cos(st[j]); y[j + 1] = y[j] + length[j] * sin(st[j]); st[j + 1] = st[j] + theta[j + 1]; } for (j = k + sq; j <= n; j += sq) { dx = x[j] - x[ind[i]]; dy = y[j] - y[ind[i]]; r = sqrt(dx * dx + dy * dy); s = acos(dx / r); if (dy < 0) s *= -1; s += ds; x[j] = x[ind[i]] + r * cos(s); y[j] = y[ind[i]] + r * sin(s); st[j] += ds; } } else if (t[i] == 1) { dl = nx[i] - length[ind[i]]; length[ind[i]] = nx[i]; j = 0; while (j + sq <= ind[i]) j += sq; k = j + sq; for (; j <= k; j++) { x[j + 1] = x[j] + length[j] * cos(st[j]); y[j + 1] = y[j] + length[j] * sin(st[j]); st[j + 1] = st[j] + theta[j + 1]; } dx = dl * cos(st[ind[i]]); dy = dl * sin(st[ind[i]]); for (j = k + sq; j <= n; j += sq) { x[j] += dx; y[j] += dy; } } else { j = 0; while (j + sq <= ind[i]) j += sq; k = j + sq; for (; j < k; j++) { x[j + 1] = x[j] + length[j] * cos(st[j]); y[j + 1] = y[j] + length[j] * sin(st[j]); st[j + 1] = st[j] + theta[j + 1]; } printf("%.20lf %.20lf\n", x[ind[i]], y[ind[i]]); } } return 0; }