#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
struct
{
    double x, y, z, r;
} st[200], tgt;
const double pi = acos(-1);
int main()
{
    int T, n;
    scanf("%d", &T);
    for (int t = 1; t <= T; t++)
    {
        double ans = 0;
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
            scanf("%lf%lf%lf%lf", &st[i].x, &st[i].y, &st[i].z, &st[i].r);
        scanf("%lf%lf%lf%lf", &tgt.x, &tgt.y, &tgt.z, &tgt.r);
        for (int i = 0; i < n; i++)
        {
            double x = st[i].x - tgt.x;
            double y = st[i].y - tgt.y;
            double z = st[i].z - tgt.z;
            double r = st[i].r, L = tgt.r;
            double l = sqrt(x * x + y * y + z * z);
            double v = r * r * r * pi * 4 / 3;
            if (l > L + r) continue;
            if (r + l < L)
            {
                ans += v;
                continue;
            }
            double t1 = acos((L * L + l * l - r * r) / (2 * L * l));
            double t2 = acos((r * r + l * l - L * L) / (2 * r * l));
            double h1 = L - L * cos(t1);
            double h2 = r - r * cos(t2);
            ans += (h1 * h1 * (3 * L - h1) + h2 * h2 * (3 * r - h2)) * pi / 3;
        }
        printf("Case %d: %.20lf\n", t, ans);
    }
    return 0;
}
