#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

typedef long double ld;
const ld PI = acos(-1.0);
bool eq(ld a, ld b) { return abs(a - b) < EPS; }
typedef complex<ld> Point;

ld dot(Point a, Point b)
{
	return real(conj(a)*b);
}

ld cross(Point a, Point b)
{
	return imag(conj(a)*b);
}
int ccw(Point a, Point b, Point c)
{
	b -= a; c -= a;
	if (cross(b, c) > EPS) return 1;    //counter cloclwise
	if (cross(b, c) < -EPS) return -1;  //cloclwise
	if (dot(b, c) < 0) return 2;        //c--a--b on line 
	if (norm(b) < norm(c)) return -2;   //a--b--c on line
	return 0;                           //a--c--b on line
}

Point unit_vector(Point v)
{
	Point res = v / abs(v);
	return res;
}

pair<Point, Point> normal_vector(Point v)
{
	Point normal1 = v * Point(0, 1);
	Point normal2 = v * Point(0, -1);
	return make_pair(unit_vector(normal1), unit_vector(normal2));
}

Point rotate(Point P, Point O, ld theta)
{
	Point res = (P - O)*Point(cos(theta), sin(theta)) + O;
	return res;
}

int n;
ld d;

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	while (cin >> n >> d, n)
	{
		Point pl(-d, 0), pr(d, 0);
		d *= 2;
		REP(i, n)
		{
			ld l, r, t;
			cin >> l >> r >> t;
			ld dl = PI * abs((l / 180.0)) * t;
			ld dr = PI * abs((r / 180.0)) * t;
			if (l == r)
			{
				Point dir;
				auto tmp = normal_vector(pr - pl);
				Point mid((pl + pr) / Point(2, 0));
				if (ccw(pl, mid, mid + tmp.first) == 1) dir = tmp.first;
				else if (ccw(pl, mid, mid + tmp.second) == 1) dir = tmp.second;
				else assert(false);
				if (l == 0) continue;
				ld ad = l / 180.0 * PI * t;
				pl += ad * dir;
				pr += ad * dir;
			}
			else
			{
				ld rot, rad_r, rad_l;
				Point center;
				if (l * r == 0)
				{
					if (r == 0)
					{
						rot = dl / d;
						center = pr;
						if (l > 0) rot *= -1;
					}
					else if (l == 0)
					{
						rot = dr / d;
						center = pl;
						if (r < 0) rot *= -1;
					}
				}
				else if (l * r > 0)
				{
					if (abs(l) > abs(r))
					{
						rad_r = (d*dr) / (dl - dr);
						rad_l = rad_r + d;
						center = pl + rad_l*unit_vector(pr - pl);
						rot = dl / rad_l;
					}
					else
					{
						rad_l = (d*dl) / (dr - dl);
						rad_r = rad_l + d;
						center = pr + rad_r*unit_vector(pl - pr);
						rot = dl / rad_l;
					}
					if (l > r) rot *= -1;
					
				}
				else if (l * r < 0)
				{
					rad_l = dl*d / (dr + dl);
					rad_r = d - rad_l;
					center = pl + rad_l*unit_vector(pr - pl);
					rot = dl / rad_l;
					if (l > 0)
					{
						rot *= -1;
					}
				}
				pr = rotate(pr, center, rot);
				pl = rotate(pl, center, rot);
			}
		}
		Point ans = (pl + pr) / Point(2.0, 0);
		cout << ans.real() << endl << ans.imag() << endl;
	}
	return 0;
}

Measured memory_bytes: 3524