#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//ll inv(ll a, ll p) {
//	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
//}
//modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

using Point = complex<ld>;
ld dot(Point a, Point b) { return real(conj(a)*b); }
ld cross(Point a, Point b) { return imag(conj(a)*b); }
struct Line {
	Point a, b;
};
struct Circle {
	Point p; ld r;
};

Point proj(Line l, Point p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}
ld dist_lp(Line l, Point p) {
	return abs(p - proj(l, p));
}

int n,d;

ld c_arc(ld r, ld len) {
	return (len / r);
	/*ld alp = 2 * r*pi;
	len = len - alp * (int)(len / alp);
	return 2*pi*(len / alp);*/
}

void yaru(Point &le,Point &ri,ld l,ld r,ld t) {
	ld cl = t * (2 * pi)*l / 360.0;
	ld cr = t * (2 * pi)*r / 360.0;
	if (l == r) {
		ld theta = atan2(imag(ri) - imag(le), real(ri) - real(le));
		theta += pi / 2.0;
		ld ad = cl;
		Point pro = { ad*cos(theta),ad*sin(theta) };
		le += pro; ri += pro; return;
	}
	else if (l == 0) {
		ld theta = atan2(imag(ri) - imag(le), real(ri) - real(le));
		theta += c_arc(2 * d, cr);
		Point pro = { 2 * d*cos(theta),2 * d*sin(theta) };
		ri = le + pro;
	}
	else if (r == 0) {
		ld theta = atan2(imag(le) - imag(ri), real(le) - real(ri));
		theta += c_arc(2 * d, -cl);
		Point pro = { 2 * d*cos(theta),2 * d*sin(theta) };
		le = ri + pro;
	}
	else if (l*r < 0) {
		ld s = abs(cl) / (abs(cl) + abs(cr));
		Point mid = s * ri + (1 - s)*le;
		ld theta = atan2(imag(ri) - imag(le), real(ri) - real(le));
		theta += c_arc((1-s)*(2 * d), cr);
		Point pro = {(1- s) * 2 * d*cos(theta),(1-s) * 2 * d*sin(theta) };
		ri = mid + pro;
		pro = { s * 2 * d*cos(theta + pi),s * 2 * d*sin(theta + pi) };
		le = mid + pro;
	}
	else if (abs(l) > abs(r)) {
		ld x = l / r;

		ld theta = atan2(imag(ri) - imag(le), real(ri) - real(le));
		ld l1 = 2 * d / (x - 1);
		Point pro = { l1*cos(theta),l1*sin(theta) };
		Point mid = ri + pro;
		//cout << l1 << endl;
		theta += pi;
		theta += c_arc(l1, -cr);
		//cout << c_arc(l1, -cr) << endl;
		pro = { l1*cos(theta),l1*sin(theta) };
		ri = mid + pro;
		le = ri + pro * (ld)(2 * d) / l1;
	}
	else {
		ld x = r / l;
		ld theta = atan2(imag(le) - imag(ri), real(le) - real(ri));
		ld l1 = 2 * d / (x - 1);
		Point pro = { l1*cos(theta),l1*sin(theta) };
		Point mid = le + pro;
		theta += pi;
		theta += c_arc(l1, cl);
		pro = { l1*cos(theta),l1*sin(theta) };
		le = mid + pro;
		ri = le + pro * (ld)(2 * d) / l1;
	}
}
void solve() {
	cin >> d;
	Point le, ri;
	le = { (ld)-d,0 };
	ri = { (ld)d,0 };
	rep(i, n) {
		int l, r, t; cin >> l >> r >> t;
		yaru(le, ri, l, r, t);
	}
	Point mid = (le + ri) / (ld)2.0;
	ld x = real(mid), y = imag(mid);
	cout << x << endl;
	cout << y << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(5);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	while (cin >> n, n)solve();
	//solve();
	stop
		return 0;
}



Measured memory_bytes: 3560