#include<cstdio>
#include<algorithm>
#include<cmath>
int x[8],y[8],o[8],sx,sy;
//double vx[8],vy[8],v;
int vx[8],vy[8],v;
const double delay = 1.00/12;
/*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;
}*/
long long dt2(int vx,int vy,long long x,long long y,long long t){
	long long l = t,r=99999999,m;
	for(;l+1<r;){
		m = l+r >> 1;
		if( hypot(x+vx*(m-1) ,y + vy*(m-1))<=(m-delay)*v)
			r= m;else l=m;
	}
	return r-1;
}
int main(){
	for(int Tc=0,n;scanf("%d",&n) , n;){
		for(int i=0;i<n;++i){
			scanf("%d%d%d%d",x+i,y+i,vx+i,vy+i);
			//vx[i]/=3600;
			//vy[i]/=3600;
			o[i]=i;
		}
		scanf("%d %d %d",&sx,&sy,&v);
		//v/=3600;
		double ans = 1e100,tmp;
		do{
			long long xx=sx,yy=sy,t=0,tt;
			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]);
				t =(double)((long long)(t+0.9999999));
				xx = x[k]+vx[k]*t; 
				yy = y[k]+vy[k]*t;*/
				tt = dt2(vx[k],vy[k],x[k]-xx,y[k]-yy,t);
				xx = x[k]+vx[k]*tt;
				yy = y[k]+vy[k]*tt;
			}
			tmp =t+ hypot(xx-sx ,yy-sy)/v;
			if(tmp<ans)ans =tmp;
		}while(std::next_permutation(o,o+n));
		ans *= 3600;
		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
*/
