typedef long long ll; typedef long double ld; #include using namespace std; #define int long long // #include // namespace mp = boost::multiprecision; // mp::cpp_int x = 1; struct UnionFind { vector par; UnionFind() { } UnionFind(int n) : par(n, -1) { } void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; signed main(){ ll n; std::cin >> n; UnionFind uf(n); for (int i = 0; i < n*(n-1)/2; i++) { ll a,b; string c; std::cin >> a>>b>>c; a--;b--; if(uf.issame(a,b))continue; uf.merge(a,b); if(uf.size(a)==n){ std::cout << c << std::endl; break; } } }