#include <bits/stdc++.h>
using namespace std;
int m = 7 * 1e5;
int main() {
    int t;
    cin >> t;

    int n,a[m],b[m],c[m],ma;
    for(int T = 0; T < t; T++)
    {
        cin >> n;
        ma = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> a[i] >> b[i] >> c[i];
            if(c[i] > ma)
            {
                ma = c[i];
            }
        }

        cout << ma << "\n";
    }
}