#include<iostream>
#include<cmath>
using namespace std;
typedef struct node
{
double x,y,z;
double I;
}Node;
Node point[101];
double distence(Node c,double a,double b)
{
double sum = (c.x - a)*(c.x - a)+(c.y - b)*(c.y - b)+c.z*c.z;//计算光源点到地面点的距离
return sum;
}
int main()
{
int text;
cin>>text;
while(text--)
{
int n;
int i,j,k;
cin>>n;
double maxs = 0.0;
for(i =1; i <= n;i++)
cin>>point[i].x>>point[i].y>>point[i].z>>point[i].I;
for(i = -100;i <= 100;i++)//枚举xy平面上从-100到100的xy所有的点,找出最大的
for(j = -100;j <= 100;j++)
{
double sum = 0.0;
for(k = 1;k <= n;k++)
{
double R;
R = distence(point[k],i,j);
sum += (point[k].I /(R))*(point[k].z/sqrt(R));//计算光强度
}
if(sum > maxs)
maxs = sum;
}
printf("%.2lf\n",maxs);
}
return 0;
}