Fatima commutes from KTH to home by subway every day. Today Robert decided to surprise Fatima by baking cookies and bringing them to an intermediate station. Fatima does not always take the same route home, because she loves to admire the artwork inside different stations in Stockholm. However, she always optimizes her travel by taking the shortest route. Can you tell Robert which station he should go to in order to surely intercept Fatima?

-----Input-----
The first line contains two integers $N$ and $M$, $1 \leq N,M \leq 100000$, where $N$ is the number of subway stations and $M$ is the number of subway links. $M$ lines follow, each with three integers $u$, $v$, $w$, $0 \leq u,v < N$, $0 < w \leq 1000000000$, meaning that there is a one-way link from $u$ to $v$ that takes $w$ seconds to complete. Note that different subway lines may serve the same route.

The last line contains two integers $s$ and $t$, $0 \leq s,t < N$ the number of the station closest to KTH and closest to home, respectively. It is possible to reach $t$ from $s$.

-----Output-----
A space separated list of all the station numbers $u$ such that all shortest paths from $s$ to $t$ pass through $u$, in increasing order.

-----Examples-----
Sample Input:
4 4
0 1 100
0 2 100
1 3 100
2 3 100
0 3
Sample Output:
0 3

Source: kattis | Difficulty: HARD
Tags: Graph algorithms


Solutions: