#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>


using namespace std;
#define ll long long
#define endl '\n'
#define itn int

const long long oo=1000000000000;

int main()
{

//    ios_base::sync_with_stdio(0);
//    cin.tie(0);
//    cout.tie(0);


    ll test;
    cin>>test;
    while(test--)
    {

        ll n;
        cin>>n;
        vector<ll>g(2*n+1,0);
        ll a[n+1],b[n+1],c;
        for(itn i=0; i<n; i++)
        {

            cin>>a[i]>>b[i]>>c;
            g[a[i]]+=c;
            g[b[i]]+=c;
        }
        ll mx=0;
        for(itn i=1; i<=2*n; i++)
        {
            mx=max(mx,g[i]);

        }
        cout<<mx<<endl;
    }

}
