#jag2017autumnd. [jag2017autumn_d]Revenge of the Broken Door

[jag2017autumn_d]Revenge of the Broken Door

MathJax.Hub.Config({ tex2jax: { inlineMath: [["","",""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 16px; line-height: 18px; background-color: #f5f5f5; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }

Problem Statement

The JAG Kingdom consists of NN cities and MM bidirectional roads. The ii-th road (u_i,v_i,c_i)(u\_i,v\_i,c\_i) connects the city u_iu\_i and the city v_iv\_i with the length c_ic\_i. One day, you, a citizen of the JAG Kingdom, decided to go to the city TT from the city SS. However, you know that one of the roads in the JAG Kingdom is currently under construction and you cannot pass the road. You don't know which road it is. You can know whether a road is under construction only when you are in either city connected by the road.

Your task is to minimize the total length of the route in the worst case. You don't need to decide a route in advance of departure and you can choose where to go next at any time. If you cannot reach the city TT in the worst case, output -1.


Input

The input consists of a single test case formatted as follows.

NN MM SS TT u_1u\_1 v_1v\_1 c_1c\_1 vdots\\vdots u_Mu\_M v_Mv\_M c_Mc\_M

The first line contains four integers NN, MM, SS, and TT, where NN is the number of the cities (2leqNleq100,0002 \\leq N \\leq 100{,}000), MM is the number of the bidirectional roads (1leqMleq200,0001 \\leq M \\leq 200{,}000), SS is the city you start from (1leSleN1 \\le S \\le N), and TT is the city you want to reach to (1leTleN1 \\le T \\le N, SneqTS \\neq T). The following MM lines represent road information: the ii-th line of the MM lines consists of three integers u_iu\_i, v_iv\_i, c_ic\_i, which means the ii-th road connects the cities u_iu\_i and v_iv\_i (1lequ_i,v_i,leqN1 \\leq u\_i, v\_i, \\leq N, u_ineqv_iu\_i \\neq v\_i) with the length c_ic\_i (1leqc_ileq1091 \\leq c\_i \\leq 10^9). You can assume that all the pairs of the cities are connected if no road is under construction. That is, there is at least one route from city xx to city yy with given roads, for all cities xx and yy. It is also guaranteed that there are no multiple-edges, i.e., u_i,v_inequ_j,v_j\\{u\_i, v\_i\\} \\neq \\{u\_j, v\_j\\} for all 1lei<jleM1 \\le i < j \\le M.

Output

Output the minimum total length of the route in the worst case. If you cannot reach the city TT in the worst case, output -1.


Sample Input 1

3 3 1 3
1 2 1
2 3 5
1 3 3

Output for Sample Input 1

6

Sample Input 2

4 4 1 4
1 2 1
2 4 1
1 3 1
3 4 1

Output for Sample Input 2

4

Sample Input 3

5 4 4 1
1 2 3
2 3 4
3 4 5
4 5 6

Output for Sample Input 3

-1