#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

typedef complex<double> Point;
const double EPS = 1e-8;
Point rotate(Point a, double b, Point c = Point()){
    return (a - c) * polar(1.0, b) + c;
}
int sign(double x){
    if(x > 0) return 1;
    if(x < 0) return -1;
    return 0;
}

int main(){
    int N, D;
    while(cin >> N >> D && N){
        Point lp = Point(-D, 0);
        Point rp = Point( D, 0);

        for(int i = 0; i < N; i++){
            double vl, vr, t;
            cin >> vl >> vr >> t;
            vl = vl / 180 * M_PI;
            vr = vr / 180 * M_PI;
            if(vl == vr){
                Point dir = rotate(rp - lp, M_PI / 2);
                dir /= abs(dir);
                lp += vl * t * dir;
                rp += vr * t * dir;
            }else if(sign(vl) * sign(vr) >= 0){
                Point center = lp + (rp - lp) / (abs(vl) - abs(vr)) * abs(vl);
                double th;
                if(sign(vl) != 0) th = abs(vl) * t / abs(lp - center);
                else              th = abs(vr) * t / abs(rp - center);
                lp = rotate(lp, (abs(vl) < abs(vr) ? 1 : -1) * sign(vl) * th, center);
                rp = rotate(rp, (abs(vl) < abs(vr) ? 1 : -1) * sign(vr) * th, center);
            }else {
                Point center = lp + (rp - lp) / (abs(vl) + abs(vr)) * abs(vl);
                double th = abs(vl) * t / abs(lp - center);
                assert(abs(th - abs(vr) * t / abs(rp - center) < EPS));
                lp = rotate(lp, -1 * sign(vl) * th, center);
                rp = rotate(rp, +1 * sign(vr) * th, center);
            }
        }
        assert(abs(abs(rp - lp) - 2 * D) < EPS);
        Point answer = (lp + rp) / 2.0;
        printf("%.5f\n%.5f\n", answer.real(), answer.imag());
    }
    return 0;
}