#include <set>
#include <cmath>
#include <stack>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <numeric>
#include <vector>
#include <ctime>
#include <queue>
#include <list>
#include <map>
#define pi acos(-1.0)
#define INF 0x3f3f3f3f
#define clr(x)  memset(x,0,sizeof(x));
#define clrto(x,siz,y)  for(int xx=0;xx<=siz;xx++)  x[xx]=y;
#define clrset(x,siz)  for(int xx=0;xx<=siz;xx++)  x[xx]=xx;
#define clr_1(x) memset(x,-1,sizeof(x));
#define clrmax(x) memset(x,0x3f,sizeof(x));
#define clrvec(x,siz) for(int xx=0;xx<=siz;xx++)  x[xx].clear();
#define fop2   freopen(".in","r",stdin); //freopen(".out","w",stdout);
#define fop   freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
#define myprogram By_135678942570
#define clrcpy(x,siz,y)  for(int xx=0;xx<siz;xx++)  x[xx]=y[xx];
#define pb push_back
#define eps 1e-8
using namespace std;
struct point
{
	double x,y;
	point(double a=0,double b=0)
	{
		x=a,y=b;
	}
	point operator + (point a)
	{
		return point(x+a.x,y+a.y);
	}
	point operator - (point a)
	{
		return point(x-a.x,y-a.y);
	}
	point operator * (double a)
	{
		return point(x*a,y*a);
	}
	point operator /(double a)
	{
		return point(x/a,y/a);
	}
};
double dis(point a,point b)
{
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
point go(point a,point b,double D)
{
	a=a-b;
	b.x=b.x+a.x*cos(D)-a.y*sin(D);
	b.y=b.y+a.x*sin(D)+a.y*cos(D);
	return b;
}
int main()
{
	// fop;
	int n;
	double d;
	while(scanf("%d%lf",&n,&d)>0)
	{
		if(n==0&&d==0)
			break;
		point left=point(-d,0);
		point right=point(d,0);
		for(int i=0;i<n;i++)
		{
			double v1,v2,t;
			scanf("%lf%lf%lf",&v1,&v2,&t);
			if(fabs(v1-v2)<eps)
			{
				point dir;
				dir.x=-right.y+left.y;
				dir.y=right.x-left.x;
				dir=dir/(sqrt(dir.x*dir.x+dir.y*dir.y));
				left=left+dir*t*v1*pi/180.0;
				right=right+dir*t*v2*pi/180.0;
			}
			else if(v1*v2>0)
			{	
				if(fabs(v1)>fabs(v2))
				{
					point O=right+(right-left)*fabs(v2)/(fabs(v1)-fabs(v2));
					left=go(left,O,-(v1*t*pi)/180.0/dis(left,O));
					right=go(right,O,-(v2*t*pi)/180.0/dis(right,O));
				}
				else
				{
					point O=left+(left-right)*fabs(v1)/(fabs(v2)-fabs(v1));
					left=go(left,O,(v1*t*pi)/180.0/dis(left,O));
					right=go(right,O,(v2*t*pi)/180.0/dis(right,O));
				}
			}
			else
			{
					point O=left+(right-left)*fabs(v1)/(fabs(v1)+fabs(v2));
					if(fabs(dis(left,O))>eps)
					left=go(left,O,-(v1*t*pi)/180.0/dis(left,O));
					if(fabs(dis(right,O))>eps)
					right=go(right,O,(v2*t*pi)/180.0/dis(right,O));
			}
		}
		point res=left+right;
		res=res/2.0;
		if(abs(res.x)<eps)
			res.x=0.0;
		if(abs(res.y)<eps)
			res.y=0.0;
		
		printf("%.14f\n%.14f\n",res.x,res.y);
	}
}