Road

아직 제출이 없습니다시간 제한6초메모리 제한1024 MB

문제

There are nn cities in a country connected by mm bidirectional roads. The cities are numbered 1,2,,n1, 2, \dots, n and the roads are numbered 1,2,,m1, 2, \dots, m. Road ii connects city u_iu\_i and city v_iv\_i, and its length is w_iw\_i meters. Starting from any city, you may reach any other city via the roads.

The roads are built in a special way. Formally, a simple cycle passing through ll roads (here, a simple cycle means a cycle such that no cities are visited twice except the start) may be represented as c_1c_2c_l1c_lc\_1 \to c\_2 \to \dots \to c\_{l-1} \to c\_l such that for all 1i<l1 \le i < l, city c_ic\_i and city c_i+1c\_{i+1} are connected directly by a road, city c_1c\_1 and city c_lc\_l are connected directly by a road, and for all 1i<jl1 \le i < j \le l, we have c_ic_jc\_i \ne c\_j. If l>3l > 3, then the roads satisfy the following additional constraint: there exist two non-adjacent cities on the cycle such that the two cities are directly connected by a road, or in other words, there exists 1u<vl1 \le u < v \le l such that vu2v-u \ge 2u,vu,v are not 11 and ll simultaneously, and city c_uc\_u and city c_vc\_v are directly connected by a road.

Now the country is going to find a route to renovate between city ss and city tt. Since the road will be inaccessible during renovation, the country wants to make sure it is possible to reach all other cities starting from any city in the country via the remaining roads during renovation (i.e. roads that are not included in the route to be renovated).

Please find a possible route to renovate and make sure the length is as short as possible.

입력

The first line contains two integers n,mn,m denoting the number of cities and the number of roads. The following mm lines contain three integers u_i,v_i,w_iu\_i,v\_i,w\_i each denoting the endpoints of the roads and the lengths. It is guaranteed that each road connects two different cities, or in other words, u_iv_iu\_i \ne v\_i. The last line contains two integers s,ts,t denoting the endpoints of the route to be renovated.

출력

The output contains only one integer denoting the minimum possible length of the route to be renovated satisfying the constraints specified in the problem. If there are no feasible solutions, output -1.

제한

For all test cases, 2n5×1052 \le n \le 5 \times 10^52m1062 \le m \le 10^6sts \ne t1u_i,v_in1 \le u\_i,v\_i \le nu_iv_iu\_i \ne v\_i1w_i1091 \le w\_i \le 10^9. It is guaranteed for any two roads their endpoints are not entirely the same. It is guaranteed the roads satisfy the conditions specified in the problem.