import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class solution2 {

    private static final int MAX_N = 16;

    private void work() {

        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(
                System.in), 1 << 16));
        double[] sx = new double[MAX_N];
        double[] sy = new double[MAX_N];
        double[] vx = new double[MAX_N];
        double[] vy = new double[MAX_N];
        double Hx, Hy, Hv;
        int n, tc = 1;
        while (true) {
            n = sc.nextInt();
            if (n == 0)
                break;
            for (int i = 0; i < n; i++) {
                sx[i] = sc.nextInt();
                sy[i] = sc.nextInt();
                vx[i] = sc.nextInt();
                vy[i] = sc.nextInt();
            }
            Hx = sc.nextInt();
            Hy = sc.nextInt();
            Hv = sc.nextInt();

            int[] p = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = i;
            }
            double best = Double.POSITIVE_INFINITY;
            do {
                double t = 0;
                double hx = Hx;
                double hy = Hy;
                for (int i = 0; i < n; i++) {
                    double next = getIntersectionTime(hx, hy, sx[p[i]] + t
                            * vx[p[i]], sy[p[i]] + t * vy[p[i]], vx[p[i]],
                            vy[p[i]], Hv) + 1;
                    t += next;
                    hx = sx[p[i]] + t * vx[p[i]];
                    hy = sy[p[i]] + t * vy[p[i]];
                }
                t += Math.sqrt((hx - Hx) * (hx - Hx) + (hy - Hy) * (hy - Hy))
                        / Hv;
                if (t < best)
                    best = t;
            } while (nextPerm(p));
            long time = Math.round(Math.ceil(3600 * best - 1e-9));
            System.out.printf(
                    "Case %d: %d hour(s) %d minute(s) %d second(s)\n", tc++,
                    time / 3600, (time % 3600) / 60, time % 60);
        }
        System.out.close();
    }

    private double getIntersectionTime(double hx, double hy, double sx,
            double sy, double vx, double vy, double hv) {
        double dx = hx - sx;
        double dy = hy - sy;
        double A = hv * hv - vx * vx - vy * vy;
        double B = dx * vx + dy * vy;
        double C = -dx * dx - dy * dy;
        double D = Math.sqrt(B * B - A * C);
        double t = -B - D;
        if (t < -1e-10)
            t = -B + D;
        return t / A;
    }

    private boolean nextPerm(int[] a) {
        if (a.length <= 1) {
            return false;
        }
        int i = a.length - 1;
        while (a[i - 1] >= a[i]) {
            i--;
            if (i == 0) {
                return false;
            }
        }
        int j = a.length;
        while (a[j - 1] <= a[i - 1]) {
            j--;
            if (j == 0) {
                return false;
            }
        }
        int tmp = a[i - 1];
        a[i - 1] = a[j - 1];
        a[j - 1] = tmp;
        i++;
        j = a.length;
        while (i < j) {
            tmp = a[i - 1];
            a[i - 1] = a[j - 1];
            a[j - 1] = tmp;
            i++;
            j--;
        }
        return true;
    }

    public static void main(String[] args) {
        new solution2().work();
    }

}
