#include<bits/stdc++.h>
using namespace std;

typedef complex<double> P;
struct state{
  P c, v;
  state(){
    c = P(0,0);
    v = P(0,1);
  }
};

const double EPS = 1E-12;
int N;
double D;

double getAngle(P a){
  return atan2(a.imag(),a.real());
}

double getAngle(P a,P b){
  return atan2(b.imag() - a.imag(),b.real() - a.real());
}
P getVec(double an){
  return P(cos(an),sin(an));
}

void move(int L,int R,int t,state &s){
  if( L == R  ){ //front or back
    s.c += s.v * ((double)L/180.0 * M_PI * (double)t);
  } else if( L == -R ) {// rotate
    double an = getAngle(s.v);
    double mva = (double) L * (double)t / 180.0 / D * M_PI;
    //    cout << "before " << an / M_PI * 180.0 << endl;
    an -= mva;
    // cout << mva / M_PI * 180.0 << " "<< an / M_PI * 180.0 << endl;
    s.v = getVec(an);
    //    cout << "vec " << s.v << endl;
  } else if( abs(L) > abs(R) ) {
    double Rd = (double)R * M_PI / 180.0;
    double Ld = (double)L * M_PI / 180.0;
    double r = 2.0 * D * Rd / ( Ld - Rd );
    double mva = (double)t*(Ld - Rd) / 2.0 / D;
    // cout << r  << " "<< mva/M_PI*180.0 << endl;
    if( (R<0&&L>0) || (R>0&&L<0) ){
      P cv1 = P( -s.v.imag(),  s.v.real() );//left
      P cv2 = P( s.v.imag(), -s.v.real() ); //right
      P lv = s.c + cv1*D;
      P rv = s.c + cv2*D;
      
      P c = rv - cv2 * abs(r);//?????¢??????     

      //    cout << lv << " - " << rv << " : " << c << endl;

      double anL= getAngle( c, lv );
      //       cout << "before : " << anL/M_PI*180.0 << endl;
      anL -= mva;
      P vL = getVec(anL);
      //cout << anL / M_PI * 180.0 << endl;
      //cout << vL << endl;
      lv = c + vL * (2.0*D - abs(r));
      double anR = getAngle( c, rv );
      anR -= mva;
      P vR = getVec(anR);
      rv = c + vR * abs(r);
      //      cout << lv << " "<< rv << endl;
      s.c = lv + (rv-lv)/2.0;
      P kv = rv-lv;
      s.v = P( -kv.imag(), kv.real() ) / abs(kv);
    } else {
      P cv = P( -s.v.imag(), s.v.real() );//left
      P mp = s.c - cv * (abs(r)+D);
      //    cout << r << " "<< mp << " "<< mva/M_PI*180.0 << endl;
      double an = getAngle(cv);
      // cout<<"before : " <<an/M_PI*180.0 << endl;
      an -= mva;
      s.v = getVec(an);
      //cout << an/M_PI*180.0 << " s.v " << s.v << endl;
      s.c = mp + s.v * (abs(r)+D);
      s.v = P( s.v.imag(), - s.v.real() );    
    //cout << "vec " << s.v << endl;
    }
  } else { // abs( R ) > abs( L )
    double Rd = (double)R * M_PI / 180.0;
    double Ld = (double)L * M_PI / 180.0;
    double r = 2.0 * D * Ld / ( Rd - Ld );
    double mva = (double)t*(Rd - Ld) / 2.0 / D;
    //   cout << r  << " "<< mva/M_PI*180.0 << endl;
    if( (R<0&&L>0) || (R>0&&L<0) ){
      P cv1 = P( -s.v.imag(),  s.v.real() );//left
      P cv2 = P( s.v.imag(), -s.v.real() ); //right
      P lv = s.c + cv1*D;
      P rv = s.c + cv2*D;

      P c = lv - cv1 * abs(r);//?????¢??????     

      //      cout << lv << " - " << rv << " : " << c << endl;

      double anL= getAngle( c, lv );
      //  cout << "before : " << anL/M_PI*180.0 << endl;
      anL += mva;
      P vL = getVec(anL);
      //cout << anL / M_PI * 180.0 << endl;
      //cout << vL << endl;
      lv = c + vL * abs(r);
      double anR = getAngle( c, rv );
      anR += mva;
      P vR = getVec(anR);
      rv = c + vR * (2.0*D - abs(r));
      //      cout << lv << " "<< rv << endl;
      s.c = lv + (rv-lv)/2.0;
      P kv = rv-lv;
      s.v = P( -kv.imag(), kv.real() ) / abs(kv);
    } else {
      P cv = P( s.v.imag(),  -s.v.real() );//right
      P mp = s.c - cv * (abs(r)+D);
      double an = getAngle(mp,s.c);
      an += mva;
      s.v = getVec(an);
      //   cout << an/M_PI * 180.0 << " " << s.v << endl;
      s.c = mp + s.v * (abs(r)+D);
      s.v = P( -s.v.imag(), s.v.real() );    
      //cout << "vec " << s.v << endl;
    }
  }
}

int main(){
  int d;
  while( cin >> N >> d && ( N||d ) ){
    D = d;
    state s;
    for(int i=0;i<N;i++){
      int L,R,T;
      cin >> L >> R >> T;
      move(L,R,T,s);
      //printf("(%d,%d,%d) :-> ( %.10lf ,%.10lf )\n",L,R,T,s.c.real()+EPS,s.c.imag()+EPS);
      //cout << s.v << endl;
    }
    printf("%.10lf\n%.10lf\n",s.c.real()+EPS,s.c.imag()+EPS);
  }
}

Measured memory_bytes: 1292