#include<bits/stdc++.h>
using namespace std;
int a[10005],b[10005],c[10005];
int n;
double ans(double x,int id){
return x*x*a[id]+x*b[id]+c[id];
}
double check(double x){
double cnt = ans(x,1);
for(int i = 2;i<=n;i++){
cnt = max(cnt,ans(x,i));
}
return cnt;
}
int main(){
cout<<fixed<<setprecision(4);
int t;
cin>>t;
while(t--){
cin>>n;
for(int i = 1;i<=n;i++) cin>>a[i]>>b[i]>>c[i];
double l = 0,r = 1005,jindu = 1e-11;
while(r-l>jindu){
double mid1 = l+(r-l)/3.0;
double mid2 = r-(r-l)/3.0;
if(check(mid1)>check(mid2)) l = mid1;
else r = mid2;
}
cout<<check(l)<<endl;
}
return 0;
}