#include <iostream> 
#include <sstream> 
#include <iomanip> 
#include <algorithm> 
#include <cmath> 
#include <string> 
#include <vector> 
#include <list> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <bitset> 
#include <numeric> 
#include <climits> 
#include <cfloat> 
using namespace std;

const double PI = acos(-1.0);

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
    double length() const{
        return sqrt(y * y + x * x);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
};

void rotate(Point& p, const Point& c, double dist)
{
    double r = p.dist(c);
    if(r < 1.0e-10)
        return;
    double theta = atan2(p.y - c.y, p.x - c.x);
    theta += dist / r;
    p = c;
    p.y += r * sin(theta);
    p.x += r * cos(theta);
}

int main()
{
    for(;;){
        int n, d;
        cin >> n >> d;
        if(n == 0)
            return 0;

        Point left(0, -d), right(0, d);

        while(--n >= 0){
            int speedL, speedR, time;
            cin >> speedL >> speedR >> time;

            Point v = right - left;
            v = v / v.length();

            if(speedL == speedR){
                swap(v.y, v.x);
                v.x *= -1;
                v = v * speedL / 180.0 * PI * time;
                left = left + v;
                right = right + v;
                continue;
            }

            double r = d * (speedL + speedR) / (double)(speedL - speedR);
            Point c = left + v * (d + r);
            if(r < -d){
                rotate(left, c, speedL / 180.0 * PI * time);
                rotate(right, c, speedR / 180.0 * PI * time);
            }else if(r > d){
                rotate(left, c, - speedL / 180.0 * PI * time);
                rotate(right, c, - speedR / 180.0 * PI * time);
            }else{
                rotate(left, c, - speedL / 180.0 * PI * time);
                rotate(right, c, speedR / 180.0 * PI * time);
            }
        }

        Point ret = (left + right) / 2;
        printf("%.10f\n%.10f\n", ret.x, ret.y);
    }
}