using System; using System.Collections.Generic; using static System.Console; using System.Linq; class yuki308 { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static long[] LList => ReadLine().Split().Select(long.Parse).ToArray(); static string[] SList(int n) => Enumerable.Repeat(0, n).Select(_ => ReadLine()).ToArray(); static void Main() { var n = NN; var map = new Pair[n * (n - 1) / 2]; for (var i = 0; i < map.Length; ++i) { var c = ReadLine().Split(); map[i] = new Pair(int.Parse(c[0]) - 1, int.Parse(c[1]) - 1, c[2]); } Array.Sort(map); var uf = new UnionFindTree(n); var r = ""; foreach (var way in map) { if (!uf.IsSameTree(way.TA, way.TB)) { uf.Unite(way.TA, way.TB); r = way.Str; } } WriteLine(r); } class Pair : IComparable { public int TA; public int TB; public string Str; public Pair(int a, int b, string str) { TA = a; TB = b; Str = str; } public int CompareTo(Pair b) { var c = Str.Length.CompareTo(b.Str.Length); if (c != 0) return c; return Str.CompareTo(b.Str); } } class UnionFindTree { int[] roots; public UnionFindTree(int size) { roots = new int[size]; for (var i = 0; i < size; ++i) roots[i] = -1; } public int GetRoot(int a) { if (roots[a] < 0) return a; return roots[a] = GetRoot(roots[a]); } public bool IsSameTree(int a, int b) { return GetRoot(a) == GetRoot(b); } public bool Unite(int a, int b) { var x = GetRoot(a); var y = GetRoot(b); if (x == y) return false; if (-roots[x] < -roots[y]) { var tmp = x; x = y; y = tmp; } roots[x] += roots[y]; roots[y] = x; return true; } public int GetSize(int a) { return -roots[GetRoot(a)]; } } }