#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<complex>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef complex<double> P;

const int inf=1<<28;
const double INF=1e12,EPS=1e-9;
const double PI=acos(-1.0);

int n,l;
P rot(P center,double theta,P p){
	p-=center; p*=P(cos(theta),-sin(theta));
	return center+p;
}
	
int main()
{
	while(scanf("%d%d",&n,&l),n){
		P c(0,0),d(0,1);
		rep(i,n){
			int u,v,T; scanf("%d%d%d",&u,&v,&T);
			double t=T*PI/180;
			if(u==v){
				c+=P(u*t,0)*d;
			}
			else
			{
				P p=u==v?c:c+d*P(0,-1.0*l*(u+v)/(u-v));
				double theta=t*(u-v)/2.0/l;
				c=rot(p,theta,c);
				d*=P(cos(theta),-sin(theta));
			}
		}
		printf("%.6f\n%.6f\n",c.real(),c.imag());
	}
	return 0;
}