Question
Farthest From a Charger
In a connected undirected graph, several nodes are charging stations. A node's safety distance is its shortest distance to any charger. Find the node with the largest safety distance; break ties by smaller node number.
Input
First line: KaTeX can only parse string typed expression.
Next KaTeX can only parse string typed expression lines: edges.
Final line: KaTeX can only parse string typed expression charger nodes.
Output
Print the chosen node and its distance.
Example
Input:
6 5 2
1 2
2 3
3 4
4 5
5 6
1 6Output:3 2