HZNUOJ

Little Sub and AA

Tags:
Time Limit:  5 s      Memory Limit:   256 MB
Submission:131     AC:36     Score:98.93

Description

One day, Little Sub who lives in the city S decides to visit AA who lives in the city T .

Little Sub lives in a country consists of N cities and M bidirectional roads. However, one of the roads is currently under construction and no one can pass the road. Little Sub doesn’t know which road it is and he can know whether a road is under construction only when he is in either city connected by the road.

Please help Little Sub 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 Little Sub cannot reach the city T in the worst case, output −1.

Input

The first line contains four integers N,M,S,T(2 ≤ N ≤ 10^5,1 ≤ M ≤ 2∗10^5,1 ≤ S,T ≤ N,S != T).

The following M lines represent road information: the ith line of the M lines consists of three integers ui, vi, ci which means the ith road connects the cities ui and vi(1 ≤ ui, vi ≤ N, ui != vi) with the length ci(1 ≤ ci ≤ 10^9). It is guaranteed that there are no multiple-edges and self-loops.

It is also promised that all the pairs of the cities are connected if no road is under construction.

Output

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

Samples

input
3 3 1 3 1 2 3 2 3 2 1 3 5
output
5
input
5 4 1 5 1 2 1 1 3 1 1 4 1 4 5 1
output
-1
input
7 10 1 5 1 2 5 2 4 7 3 4 5 2 5 7 5 6 4 6 7 3 2 7 4 5 7 3 7 4 3 1 5 4
output
12

Author

CHEN, Jingbang