import java.io.PrintWriter import java.util.* fun PrintWriter.solve() { val n = nextInt() val graph = Array(n) { mutableListOf() } for (i in 0 until n * (n - 1) / 2) { val a = nextInt() - 1 val b = nextInt() - 1 val c = next() graph[a].add(b) graph[b].add(a) val visited = BooleanArray(n) { false } val stack = Stack() stack.push(0) visited[0] = true while (stack.isNotEmpty()) { val v = stack.pop() for (w in graph[v]) { if (!visited[w]) { stack.push(w) visited[w] = true } } } if (visited.all { it }) { println(c) return } } } fun main() { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() // endregion