#include using namespace std; struct unionfind{ vector p; unionfind(int N){ p = vector(N, -1); } int root(int x){ if (p[x] < 0){ return x; } else { p[x] = root(p[x]); return p[x]; } } bool same(int x, int y){ return root(x) == root(y); } void unite(int x, int y){ x = root(x); y = root(y); if (x != y){ if (p[x] < p[y]){ swap(x, y); } p[y] += p[x]; p[x] = y; } } }; int main(){ int N; cin >> N; unionfind UF(N); int cnt = 0; for (int i = 0; i < N * (N - 1) / 2; i++){ int a, b; string C; cin >> a >> b >> C; a--; b--; if (!UF.same(a, b)){ UF.unite(a, b); cnt++; if (cnt == N - 1){ cout << C << endl; break; } } } }