/****************************************************************************************************
第一次写三分~居然是拿regional题练的。。。
****************************************************************************************************/
#include <iostream>
#include <functional>
#include <algorithm>
//#include <hash_map> //Visual C++ lib
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <sstream>
#include <utility>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <limits>
#include <memory>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;
#define LOWBIT(x) ( (x) & ( (x) ^ ( (x) - 1 ) ) )
#define CLR(x, k) memset((x), (k), sizeof(x))
#define CPY(t, s) memcpy((t), (s), sizeof(s))
#define SC(s) static_cast<int>(s)
#define LEN(s) static_cast<int>( strlen((s)) )
#define SZ(s) static_cast<int>( (s).size() )
typedef double LF;
//typedef long long LL; //GNU C++
//typedef unsigned long long ULL;
typedef __int64 LL; //Visual C++ 2010
typedef unsigned __int64 ULL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
//typedef hash_map<int, int>::iterator HMI;
typedef map<int, int>::iterator MI;
typedef vector<int>::iterator VI;
typedef list<int>::iterator LI;
typedef set<int>::iterator SI;
const int INF_INT = 0x3f3f3f3f;
const LL INF_LL = 0x7fffffffffffffffLL; //15f
const double oo = 10e9;
const double eps = 10e-9;
const double PI = acos(-1.0);
const int MAXN = 10004;
struct Qua
{
LF a, b, c;
}qua[MAXN];
int test, n;
LF fun(const Qua &q, const LF &x)
{
return q.a * x * x + q.b * x + q.c;
}
LF getmax(const LF &x)
{
LF mx = fun(qua[0], x);
for (int i = 1; i < n; ++i)
{
mx = max(mx, fun(qua[i], x));
}
return mx;
}
LF trisearch()
{
LF l = 0.0, r = 1004.0, m1, m2;
while (r - l > eps)
{
m1 = (2.0 * l + r) / 3.0;
m2 = (l + 2.0 * r) / 3.0;
if (getmax(m2) > getmax(m1))
{
r = m2;
}
else
{
l = m1;
}
}
return (l + r) * 0.5;
}
void ace()
{
for (cin >> test; test--; )
{
cin >> n;
for (int i = 0; i < n; ++i)
{
cin >> qua[i].a >> qua[i].b >> qua[i].c;
}
printf("%.4lf\n", getmax( trisearch() ));
}
return ;
}
int main()
{
ace();
return 0;
}