Bumped!

Given an undirected weighted road graph and up to 1000 directed free flights, find the cheapest s-to-t trip using at most one flight.

Medium7GraphShortest pathDynamic programmingHeapInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Peter is back from the ICPC World Finals. His return flight was overbooked, he lost his seat, and the airline gave him a voucher good for one free flight between two cities of his choosing.

He is already planning next year's trip. He travels by car, but he may pick one of the listed flights and spend the voucher on that leg of the trip. A leg flown on the voucher costs nothing.

You are given the network of cities and roads, the cost of the gas for each road, and the list of flights that are available. Find the smallest amount of money Peter needs to get from his home town to next year's destination.

Input

The input consists of a single test case. The first line contains five space separated integers nn, mm, ff, ss, and tt: the number of cities nn (0<n500000 < n \le 50\,000), the number of roads mm (0m1500000 \le m \le 150\,000), the number of flights ff (0f10000 \le f \le 1\,000), the number ss (0s<n0 \le s < n) of the city where Peter's trip starts, and the number tt (0t<n0 \le t < n) of the city Peter is traveling to. Cities are numbered from 00 to n1n - 1.

Each of the next mm lines describes one road with three space separated integers ii, jj, and cc (0i,j<n0 \le i, j < n, iji \ne j, 0<c500000 < c \le 50\,000), meaning that a road connects city ii and city jj and costs cc cents to travel. A road can be used in either direction for the same cost. All road descriptions are distinct.

Each of the next ff lines describes one available flight with two space separated integers uu and vv (0u,v<n0 \le u, v < n, uvu \ne v), meaning that a flight from city uu to city vv is available. That flight does not run from vv to uu unless a separate line lists it. All flight descriptions are distinct.

Output

Print the minimum number of cents Peter needs to spend to get from his home town to the destination, using at most one flight. A route to the destination always exists.