#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define sqr(x) ((x)*(x))

main(){
  FILE *vitesse = fopen("motion.out", "r"); // data stream

  double Dtau;
  double tau, vx, vy, r, theta;
  double sx, sy, x=0.0, y=0.0;
  

  fscanf(vitesse, "%lf %lf %lf %lf %lf", &tau, &vx, &vy, &r, &theta);  // read the initial conditions

  /* printf("%g\t%g\t%g\t%g\t%g\n",tau,vx,vy,r,theta); */ // test

  int m, l, M, j; 

  scanf("%d %d", &l, &M); // N = 2*l*M 
  scanf("%lf", &Dtau);

  m=-1; 
  printf("%g\t%g\t%g\n", 2*l*(m+1)*Dtau, x,y); // output the initial position
  for(m=0;m<M;m++){
    sx = vx/3.0; sy = vy/3.0;
    for(j=1;j<(2*l);j++){
      fscanf(vitesse, "%lf %lf %lf %lf %lf", &tau, &vx, &vy, &r, &theta);  // read the contribution at the instant (m*2*l+j)*Dtau
	sx = sx + (2.0/3.0)*((j%2)+1)*vx; 
	sy = sy + (2.0/3.0)*((j%2)+1)*vy; 
    }
    fscanf(vitesse, "%lf %lf %lf %lf %lf", &tau, &vx, &vy, &r, &theta);  //  read the last contribution of the m'th box; and the first contribution of the next box
    sx = sx + (1.0/3.0)*vx; 
    sy = sy + (1.0/3.0)*vy;

    x = x + Dtau*sx;
    y = y + Dtau*sy;
   

    printf("%g\t%g\t%g\n", 2*l*(m+1)*Dtau, x,y); // output the new position 

  }



  fclose(vitesse);
  
}
