#include<cstdio>
#include<algorithm>
#include<cmath>
int x[8],y[8],o[8],sx,sy;
double vx[8],vy[8],v;
const double delay = 3600;
double dt(double x,double y,double vx,double vy){
	static double a,b,c,d,x1,x2; 
	a =v*v - vx *vx -vy *vy;
	b = x * vx + y * vy;
	c =  x*x + y *y;
	d = sqrt(b * b + a* c);
	x1 = (b + d)/a; x2 =(b -d) /a;
	return  (x2>=0?x2:x1)+delay;
}
int main(){
	for(int Tc=0,n;scanf("%d",&n) , n;){
		for(int i=0;i<n;++i){
			scanf("%d%d%lf%lf",x+i,y+i,vx+i,vy+i);
			vx[i]/=3600;
			vy[i]/=3600;
			o[i]=i;
		}
		scanf("%d %d %lf",&sx,&sy,&v);
		v/=3600;
		double ans = 1e100,tmp;
		do{
			double xx=sx,yy=sy,t=0;
			for(int i=0,k;i<n;++i){
				k = o[i];
				t += dt(x[k]+t *vx[k]-xx,y[k]+t*vy[k]-yy,vx[k],vy[k]);
				xx = x[k]+vx[k]*t; 
				yy = y[k]+vy[k]*t;
			}
			tmp =t+ hypot(xx-sx ,yy-sy)/v;
			if(tmp<ans)ans =tmp;
		}while(std::next_permutation(o,o+n));
		long long ias = ans +0.99999999;
		//printf("%.12lf\n",ans);
		printf("Case %d: %lld hour(s) %lld minute(s) %lld second(s)\n",++Tc,ias/3600,
			ias/60 %60,ias %60);
	}
	return 0;
}/*
5
1 0 0 0
2 0 0 0 
3 0 0 0 
4 0 0 0
5 0 0 0
0 0 1
Case 1: 10 hour(s) 25 minute(s) 0 second(s)
3
1 2 3 4
2 2 40 23
7 8 22 10
0 0 50
Case 2: 1 hour(s) 49 minute(s) 5 second(s)
0
*/
