func findNode(from start: Int, of graph: [[(node: Int, weight: Int)]]) -> (node: Int, length: Int) { var result = (node: start, length: 0) var visited = Array(repeating: false, count: graph.count) var stack = [(node: Int, length: Int)]() stack.append(result) visited[start] = true while !stack.isEmpty { if let (now, cur_len) = stack.popLast() { if cur_len > result.length { result = (node: now, length: cur_len) } for next in graph[now] { if !visited[next.node] { visited[next.node] = true stack.append((node: next.node, length: cur_len + next.weight)) } } } } return result } if let N = Int(readLine() ?? "0") { if N == 1 { print(0) } else { var graph = Array(repeating: [(node: Int, weight: Int)](), count: N+1) for _ in 0..