class Solution:
def minScore(self, n: int, roads: List[List[int]]) -> int:
graph = defaultdict(list)
for fromNode, toNode, distance in roads:
graph[fromNode].append([toNode, distance])
graph[toNode].append([fromNode, distance])
minDistance = float("inf")
stack = [1]
seen = set()
while stack:
currNode = stack.pop()
for neighborNode, neighborDistance in graph[currNode]:
if neighborNode not in seen:
stack.append(neighborNode)
seen.add(neighborNode)
minDistance = min(minDistance, neighborDistance)
return(minDistance)