Unidentified Destination
InterviewTime limit3sMemory limit256 MB
List the candidate destinations whose shortest route from s passes through the road between g and h.
- Level
Medium5 of 10
- Topics
- Shortest path, Graph
- Solved
- No attempts yet
Problem
(kzzt) Agent B100, a pair of circus performers in loud outfits is moving through the streets of a city. Your mission is to find out where they are going. What we know is that they left from intersection , and that one of the destination candidates is their real destination. They are in a hurry, so they take a shortest route with no detours. Over. (kzzt)
Ugh, the duo (loud outfits and all) is nowhere to be seen. Luckily your nose is as good as a dog's, and it told you that the two passed along the road between intersections and .
So where on earth is this duo going? Among the destination candidates, find every point such that some shortest route from to it uses the road between and .
Input
The first line has the number of test cases (). Each test case looks like this.
- The first line has three integers , , (, , ): the number of intersections, roads, and destination candidates.
- The second line has three integers , , (, ). is where the artists started, and and are the two intersections described above.
- Each of the next lines has three integers , , (, ), meaning a two-way road of length runs between intersections and .
- Each of the next lines has one destination candidate . These points are distinct and none of them equals .
At most one road directly joins any two intersections. One of the roads joins and , and that road lies on a shortest route to at least one of the destination candidates.
Output
For each test case, print on one line the destination candidates that some shortest route from reaches through the road between and , in increasing order, separated by single spaces. At least one candidate always qualifies.