#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i) #define all(a) (a).begin(), (a).end() struct UnionFind { vector par, siz; int v, group; UnionFind(int n) { par = vector(n, -1); siz = vector(n, 1); v = n; group = n; } int root(int x) { if (par[x] == -1) return x; else return par[x] = root(par[x]); } bool same(int x, int y) { return root(x) == root(y); } bool unite(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); par[y] = x; siz[x] += siz[y]; group--; return true; } int size(int x) { return siz[root(x)]; } }; int main() { cin.tie(nullptr); int N; cin >> N; int edge = N * (N - 1) / 2; UnionFind uf(N); rep(e, 0, edge) { int a, b; string C; cin >> a >> b >> C; a--, b--; if (!uf.same(a, b)) { uf.unite(a, b); if (uf.group == 1) { cout << C << '\n'; break; } } } }