#include <cstdio>
#include <cmath>
using namespace std;
const double PI = acos(-1);
struct Point {
double x, y;
};
struct Round {
Point o;
double r;
};
double Cos(double a, double b, double c) {
return (a * a + b * b - c * c) / (2.0 * a * b);
}
double Distance(Point a, Point b) {
double dx = a.x - b.x, dy = a.y - b.y;
return sqrt(dx * dx + dy * dy);
}
double Intersection(Round a, Round b) {
double d = Distance(a.o, b.o);
if (d >= a.r + b.r)return 0;
if (a.r >= b.r + d)return PI * b.r * b.r;
if (b.r >= a.r + d)return PI * a.r * a.r;
double radian_a = acos(Cos(d, a.r, b.r)) * 2;
double radian_b = acos(Cos(d, b.r, a.r)) * 2;
double h = a.r * sin(radian_a / 2);
return (radian_a / 2) * a.r * a.r + (radian_b / 2) * b.r * b.r - d * h;
}
signed main() {
// freopen("in", "r", stdin), freopen("out", "w", stdout);
int Ts, Tp = 0;
scanf("%d", &Ts);
while (Ts--) {
double r, R;
scanf("%lf %lf", &r, &R);
double x1, y1;
scanf("%lf %lf", &x1, &y1);
double x2, y2;
scanf("%lf %lf", &x2, &y2);
Round A = {{x1, y1}, R}, B = {{x2, y2}, R}, a = {{x1, y1}, r}, b = {{x2, y2}, r};
printf("Case #%d: %lf\n", ++Tp,
Intersection(A, B) - Intersection(A, b) - Intersection(a, B) + Intersection(a, b));
}
return 0;
}