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

main()
{
	int h_deg,h_min,h_sec;
	int v_deg,v_min,v_sec;
	int debug;

	float r_dist;

	double rho, theta, phi;
	double x,y,z;
	double pi;

	int nread;

	debug = 0;

	pi = M_PI;
	if(debug) fprintf(stdout,"pi %f \n",pi);
	while( (nread = fscanf(stdin,"%d %d %d %d %d %d %f",&v_deg,&v_min,&v_sec,&h_deg,&h_min,&h_sec,&r_dist)) > 0 )
	{
		if(debug) fprintf(stderr,"\n %d %d %d %d %d %d %f\n ",h_deg,h_min,h_sec,v_deg,v_min,v_sec,r_dist);
		/*Convert minutes and seconds to degree fractions */
		theta = (double)h_deg + (double)h_min/60. + (double)h_sec/3600.;
		if(debug) fprintf(stderr,"degree theta %f \n",theta);

		/*Convert from clockwise to counter-clockwise */
		theta = 360. - theta;
		if(debug) fprintf(stderr,"fixed degree theta %f \n",theta);

		/*Convert to radians */
		theta = theta * pi / 180.;
		if(debug) fprintf(stderr,"fixed radian theta %f \n",theta);

		/*Convert minutes and seconds to degree fractions */
		phi = (double)v_deg + (double)v_min/60. + (double)v_sec/3600.;
		if(debug) fprintf(stderr,"degree phi %f \n",phi);

		/*Convert to vertical zero */
		/*phi = phi; */

		/*Convert to radians */
		phi = phi * pi / 180.;
		if(debug) fprintf(stderr,"radian phi %f \n",phi);

		rho = r_dist;
		x = rho * sin(phi)*cos(theta);
		y = rho * sin(phi)*sin(theta);
		z = rho * cos(phi);

		fprintf(stdout,"%f %f %f \n",x,y,z);
	
	}
	
}
