Officials and Roads
In the city of Floville, elections have been held for officials. The city is represented as a connected undirected graph with vertices and edges. Each edge in the graph is described by a triplet of numbers: , , and , indicating an edge between vertices and with a length of .
Each official is provided with housing. Official number resides at vertex on the graph. There are available offices in the city for the officials to work from. If official number is assigned to an office at vertex , they will commute daily from vertex to vertex , always taking the shortest path. Among all possible shortest paths, they choose based on the following rule: reverse the order of the vertices in the path (i.e., from the workplace to home) and select the "lexicographically smallest" path.
For instance, if there are two shortest paths from vertex 0 to vertex 5: 0→1→2→4→5 and 0→3→5, the official will choose the path 0→3→5. This is because, in reverse order (from workplace to home), the paths are 5→4→2→1→0 and 5→3→0. The "lexicographically smallest" is 5→3→0.
All roads (graph edges) along the official's route will be maintained in good condition.
Each official must select one office from the list such that the total length of roads maintained in good condition is maximized.
Input
The first line contains three integers , , and :
- : the number of vertices in the graph (); - : the number of edges in the graph (); - : the number of officials ().
The next lines describe the edges of the graph. Each edge is given in the format: , where is the length of the edge (), ().
The following line contains integers:
- : the vertex numbers where the officials' homes are located.
The next line contains integers:
- : the vertex numbers where the offices for the officials' future work are located.
Output
Output , the maximum total length of roads that will be guaranteed to be repaired.
Also, output : the vertex numbers where the offices for the officials' future work are located, corresponding to the maximum total length of guaranteed repaired roads .