This page is still under construction.

Parts of this page are still being built. What you see may change.

Unidentified Destination

Interview

Time limit3sMemory limit256 MB

Summary
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 ss, 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 gg and hh.

So where on earth is this duo going? Among the destination candidates, find every point such that some shortest route from ss to it uses the road between gg and hh.

Input

The first line has the number of test cases TT (1≤T≤1001 \le T \le 100). Each test case looks like this.

  • The first line has three integers nn, mm, tt (2≤n≤20002 \le n \le 2000, 1≤m≤500001 \le m \le 50000, 1≤t≤1001 \le t \le 100): the number of intersections, roads, and destination candidates.
  • The second line has three integers ss, gg, hh (1≤s,g,h≤n1 \le s, g, h \le n, g≠hg \ne h). ss is where the artists started, and gg and hh are the two intersections described above.
  • Each of the next mm lines has three integers aa, bb, dd (1≤a<b≤n1 \le a < b \le n, 1≤d≤10001 \le d \le 1000), meaning a two-way road of length dd runs between intersections aa and bb.
  • Each of the next tt lines has one destination candidate xx. These tt points are distinct and none of them equals ss.

At most one road directly joins any two intersections. One of the mm roads joins gg and hh, 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 ss reaches through the road between gg and hh, in increasing order, separated by single spaces. At least one candidate always qualifies.

Examples1

  1. Example 1

    Input
    2
    5 4 2
    1 2 3
    1 2 6
    2 3 2
    3 4 4
    3 5 3
    5
    4
    6 9 2
    2 3 1
    1 2 1
    1 3 3
    2 4 4
    2 5 5
    3 4 3
    3 6 2
    4 5 4
    4 6 3
    5 6 7
    5
    6
    
    Expected output
    4 5
    6