#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int mod = 1e9+7;
ll gcd(ll a,ll b){
if(b==0)
return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
ll ans = 1;
while(pow!=0){
if(pow&1==1){
ans = ans*base;
ans = ans%mod;
}
base *= base;base%=mod;
pow/=2;
}return ans;
}
ll inv(ll x){
return expo(x,mod-2);
}
double pi = 3.141592653589793238462643;
double error = 0.0000001;
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1}; // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/* -------Template ends here-------- */
const int M = 100001;
struct node{
int y , z , r , x;
};
int main(){
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
int T;
si(T);
for(int alp = 1 ; alp <= T ; alp++){
//int ans = 0;
int n;
si(n);
vector<node> v(n);
for(int i = 0 ; i<n ; i++){
si(v[i].x);
si(v[i].y);
si(v[i].z);
si(v[i].r);
}
ll ans = INFL;
for(int m = 0 ; m < (1<<n) ; m++){
// cout<<m<<endl;
ll xm1, ym1, zm1, xm2, ym2, zm2, xM1, yM1, zM1, xM2, yM2, zM2;
xM1 = yM1 = zM1 = xM2 = yM2 = zM2 = -INFL;
xm1 = ym1 = zm1 = xm2 = ym2 = zm2 = INFL;
for(int j = 0 ; j<n ; j++){
ll r = v[j].r;
if(m & (1<<j)){
xm1 = min(xm1, v[j].x - r); ym1 = min(ym1, v[j].y - r); zm1 = min(zm1, v[j].z - r);
xM1 = max(xM1, v[j].x + r); yM1 = max(yM1, v[j].y + r); zM1 = max(zM1, v[j].z + r);
}
else{
xm2 = min(xm2, v[j].x - r); ym2 = min(ym2, v[j].y - r); zm2 = min(zm2, v[j].z - r);
xM2 = max(xM2, v[j].x + r); yM2 = max(yM2, v[j].y + r); zM2 = max(zM2, v[j].z + r);
}
}
ans = min(ans, max(max(xM1 - xm1, xM2 - xm2), max(max(yM1 - ym1, yM2 - ym2), max(zM1 - zm1, zM2 - zm2))));
}
printf("Case #%d: " , alp);
cout<<ans<<endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIHNpKFgpIHNjYW5mKCIlZCIsICYoWCkpCiNkZWZpbmUgc2xsKFgpIHNjYW5mKCIlbGxkIiwmKFgpKQojZGVmaW5lIElORkwgMHgzZjNmM2YzZjNmM2YzZjNmTEwKY29uc3QgaW50IG1vZCA9IDFlOSs3OwpsbCBnY2QobGwgYSxsbCBiKXsKCWlmKGI9PTApCglyZXR1cm4gYTtyZXR1cm4gZ2NkKGIsYSViKTsKfQpsbCBleHBvKGxsIGJhc2UsbGwgcG93KXsKICAgIGxsIGFucyA9IDE7CiAgICB3aGlsZShwb3chPTApewogICAgICAgIGlmKHBvdyYxPT0xKXsKICAgICAgICAgICAgYW5zID0gYW5zKmJhc2U7CiAgICAgICAgICAgIGFucyA9IGFucyVtb2Q7CiAgICAgICAgfQogICAgICAgIGJhc2UgKj0gYmFzZTtiYXNlJT1tb2Q7CiAgICAgICAgcG93Lz0yOwogICAgfXJldHVybiBhbnM7Cn0KbGwgaW52KGxsIHgpewogICAgcmV0dXJuIGV4cG8oeCxtb2QtMik7Cn0KCmRvdWJsZSBwaSA9IDMuMTQxNTkyNjUzNTg5NzkzMjM4NDYyNjQzOwpkb3VibGUgZXJyb3IgPSAwLjAwMDAwMDE7CmludCBkeFs4XSA9IHsxICwgMCAsIC0xICwgMCAsIDEgLCAtMSAsIC0xICwgMX07ICAgIC8vIGxhc3QgNCBkaWFnb25hbAppbnQgZHlbOF0gPSB7MCAsIDEgLCAwICwgLTEgLCAxICwgMSAsIC0xICwgLTF9OwovKiAtLS0tLS0tVGVtcGxhdGUgZW5kcyBoZXJlLS0tLS0tLS0gKi8KCmNvbnN0IGludCBNID0gMTAwMDAxOwoKc3RydWN0IG5vZGV7CiAgICBpbnQgeSAsIHogLCByICwgeDsKfTsKCmludCBtYWluKCl7CiAgICBmcmVvcGVuKCJpbnB1dC50eHQiLCAicnQiLCBzdGRpbik7CiAgICBmcmVvcGVuKCJvdXRwdXQudHh0IiwgInd0Iiwgc3Rkb3V0KTsKCiAgICBpbnQgVDsKICAgIHNpKFQpOwoKICAgIGZvcihpbnQgYWxwID0gMSA7IGFscCA8PSBUIDsgYWxwKyspewogICAgICAgIC8vaW50IGFucyA9IDA7CiAgICAgICAgaW50IG47CiAgICAgICAgc2kobik7CgogICAgICAgIHZlY3Rvcjxub2RlPiB2KG4pOwogICAgICAgIGZvcihpbnQgaSA9IDAgOyBpPG4gOyBpKyspewogICAgICAgICAgICBzaSh2W2ldLngpOwogICAgICAgICAgICBzaSh2W2ldLnkpOwogICAgICAgICAgICBzaSh2W2ldLnopOwogICAgICAgICAgICBzaSh2W2ldLnIpOwogICAgICAgIH0KCiAgICAgICAgbGwgYW5zID0gSU5GTDsKCiAgICAgICAgZm9yKGludCBtID0gMCA7IG0gPCAoMTw8bikgOyBtKyspewogICAgICAgICAgIC8vIGNvdXQ8PG08PGVuZGw7CiAgICAgICAgICAgIGxsIHhtMSwgeW0xLCB6bTEsIHhtMiwgeW0yLCB6bTIsIHhNMSwgeU0xLCB6TTEsIHhNMiwgeU0yLCB6TTI7CiAgICAgICAgICAgIHhNMSA9IHlNMSA9IHpNMSA9IHhNMiA9IHlNMiA9IHpNMiA9IC1JTkZMOwogICAgICAgICAgICB4bTEgPSB5bTEgPSB6bTEgPSB4bTIgPSB5bTIgPSB6bTIgPSBJTkZMOwoKICAgICAgICAgICAgZm9yKGludCBqID0gMCA7IGo8biA7IGorKyl7CiAgICAgICAgICAgICAgICBsbCByID0gdltqXS5yOwoKICAgICAgICAgICAgICAgIGlmKG0gJiAoMTw8aikpewogICAgICAgICAgICAgICAgICAgICB4bTEgPSBtaW4oeG0xLCB2W2pdLnggLSByKTsgeW0xID0gbWluKHltMSwgdltqXS55IC0gcik7IHptMSA9IG1pbih6bTEsIHZbal0ueiAtIHIpOwogICAgICAgICAgICAgICAgICAgIHhNMSA9IG1heCh4TTEsIHZbal0ueCArIHIpOyB5TTEgPSBtYXgoeU0xLCB2W2pdLnkgKyByKTsgek0xID0gbWF4KHpNMSwgdltqXS56ICsgcik7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgZWxzZXsKICAgICAgICAgICAgICAgICAgICB4bTIgPSBtaW4oeG0yLCB2W2pdLnggLSByKTsgeW0yID0gbWluKHltMiwgdltqXS55IC0gcik7IHptMiA9IG1pbih6bTIsIHZbal0ueiAtIHIpOwogICAgICAgICAgICAgICAgICAgIHhNMiA9IG1heCh4TTIsIHZbal0ueCArIHIpOyB5TTIgPSBtYXgoeU0yLCB2W2pdLnkgKyByKTsgek0yID0gbWF4KHpNMiwgdltqXS56ICsgcik7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICB9CiAgICAgICAgICAgIGFucyA9IG1pbihhbnMsIG1heChtYXgoeE0xIC0geG0xLCB4TTIgLSB4bTIpLCBtYXgobWF4KHlNMSAtIHltMSwgeU0yIC0geW0yKSwgbWF4KHpNMSAtIHptMSwgek0yIC0gem0yKSkpKTsKICAgICAgICB9CgoKCiAgICAgICAgcHJpbnRmKCJDYXNlICMlZDogIiAsIGFscCk7CiAgICAgICAgY291dDw8YW5zPDxlbmRsOwoKICAgIH0KCgoKCgoKCgoKCgoKCgoKCgoKCgp9CgoKCgoKCgoKCgoKCg==