#include <bits/stdc++.h>

using namespace std;
#define pb push_back
typedef long long LL;

int n;
double x[11000], y[11000];
double w[11000];
double sx,sy;
double tx,ty;

void solve(int test){
	cout << "Case #" << test + 1 << ": " ;
	cin >> n;
		
	vector<pair<double, double> > vtx,vty;
	double S=0;
	for(int i=0; i<n; i++){
		cin >> tx >> ty >> w[i];
		//Transform
		x[i] = (tx+ty);
		y[i] = (ty-tx);		
		vtx.pb( {x[i] , w[i] } );
		vty.pb( {y[i], w[i] } );
		S += w[i];
	}
	
	//Find median
	sort(vtx.begin(), vtx.end());
	sort(vty.begin(), vty.end());
		
  	int k = 0;
  	double sum = S - vtx[0].second; 

  	while(sum > S/2){
    	++k;
    	sum -= vtx[k].second;;
  	}	
  	
	double rx = vtx[k].first;
	if(sum == S/2){
		rx = (rx + vtx[k+1].first)/2;
	}
	
	k = 0;
  	sum = S - vty[0].second; 

  	while(sum > S/2){
    	++k;
    	sum -= vty[k].second;;
  	}	
	double ry = vty[k].first;;
	if(sum == S/2){	
		ry = (ry + vty[k+1].first)/2;
	}
	double res = 0;
	for(int i=0; i<n; i++){
		res += (abs(rx-x[i]) + abs(ry-y[i]) )*w[i];
	}
	
	cout << setprecision(7) << fixed << res/2 << endl;
}

int ntest;
int main(){
	cin >> ntest;
	for(int test=0; test<ntest; test++){
		solve(test);
	}
	return 0;
}