#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef tuple<double,double,double> ddd;
#define mem(arr,val) memset((arr),(val),(sizeof(arr)))
const double eps = 1e-8;
const int INF = 0x3f3f3f;
const int Size = 2e6+5;
const double pi = acos(-1.0);
inline int sgn(double x) {return fabs(x)<eps?0:(x<0?-1:1);}
struct Point
{
int x,y;
Point(int x = 0,int y = 0):x(x),y(y){}
bool operator<(const Point p) {return x < p.x || (x == p.x && y < p.y);}
bool operator==(const Point p) {return x == p.x && y == p.y;}
Point operator+(const Point p) {return Point(x+p.x,y+p.y);}
Point operator-(const Point p) {return Point(x-p.x,y-p.y);}
};
typedef Point Vector;
inline int Cross(Vector A,Vector B) {return A.x*B.y-A.y*B.x;}
inline int Dot(Vector A,Vector B) {return A.x*B.x+A.y*B.y;}
inline double Distance(Point A,Point B) {return hypot(A.x-B.x,A.y-B.y);}
inline int Dist(Point A,Point B) {return hypot(A.x-B.x,A.y-B.y)*hypot(A.x-B.x,A.y-B.y);}
inline vector <Point> ConvexHull(vector <Point> p)
{
sort(p.begin(),p.end());
p.erase(unique(p.begin(),p.end()),p.end());
int n = p.size(),m = 0;
vector <Point> ch(n+1);
for(int i = 0;i < n;++i)
{
while(m > 1 && Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2]) <= 0) m--;
ch[m++] = p[i];
}
int k = m;
for(int i = n-2;~i;--i)
{
while(m > k && Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2]) <= 0) m--;
ch[m++] = p[i];
}
if(n > 1) --m;
ch.resize(m);
return ch;
}
inline int Diameter(vector <Point>& points)
{
vector <Point> p = ConvexHull(points);
int n = p.size();
if(n == 1) return 0;
if(n == 2) return Dist(p[0],p[1]);
p.push_back(p[0]);
int ans = 0;
for(int u = 0,v = 1;u < n;++u)
{
for(;;)
{
int diff = Cross(p[u+1]-p[u],p[v+1]-p[v]);
if(diff <= 0)
{
ans = max(ans,Dist(p[u],p[v]));
if(!diff) ans = max(ans,Dist(p[u],p[v+1]));
break;
}
v = (v+1)%n;
}
}
return ans;
}
int main(int argc,char *argv[])
{
ios::sync_with_stdio(false);cin.tie(0);
int t,n;cin>>t;
while(t--)
{
cin>>n;
vector <Point> p;
for(int i = 0,x,y,w;i < n;++i)
{
cin>>x>>y>>w;
p.push_back(Point(x,y));
p.push_back(Point(x+w,y));
p.push_back(Point(x,y+w));
p.push_back(Point(x+w,y+w));
}
cout<<Diameter(p)<<'\n';
}
return 0;
}