//这题有坑, 用C++交题才能A, G++TLE
//把图画在纸上, 直觉会告诉你, max(si(x))构成一个有凸多边形, 极值在最低处~,
//然后可以用三分, 精度至少在1e-9
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <algorithm>
//#include "myAlgorithm.h"
#define MAX 10005
#define INF (1e8 + 5)
#define eps 1e-9
#define Rep(s, e) for( int i = s; i <= e; i++)
#define Cep(e, s) for( int i = e; i >= s; i --)
using namespace std;
int T, n;
double a[MAX], b[MAX], c[MAX];
double func(int i, double val){
return a[i] * val * val + b[i] * val + c[i];
}
double get_min(){
double d = 0, u = 1000, mid, mmid, res1, res2;
while(u - d > eps){
mid = (u + d)/2; mmid = (mid + u)/2;
res1 = func(0, mid);
res2 = func(0, mmid);
Rep(1, n - 1){
res1 = max(res1, func(i, mid));
res2 = max(res2, func(i, mmid));
}
if(res1 < res2) {
u = mmid;
} else {
d = mid;
}
}
return res1;
}
int main() {
cin>>T;
//freopen("in.tx0t", "w", stdout);
while(T--){
cin>>n;
Rep(0, n - 1){
cin>>a[i]>>b[i]>>c[i];
}
printf("%.4f\n", get_min());
}
return 0;
}
/*
*/