Evacuation
면접 대비시간 제한1초메모리 제한2048 MB
무방향 가중 그래프에서 토네이도가 주어진 경로를 따라 이동하며 도착하는 다리를 파괴할 때, H에서 E로 이동하는 최단 시간을 구한다.
문제
A city specified by a set of districts and bridges is under threat. Initially, each district can reach any other district through some series of bridges.
A tornado has touched down at district and is destroying everything in its way. The latest model suggests the tornado will destroy districts following the bridges between . Upon reaching district the model is not accurate enough to precisely determine the tornadoes course.
Given the tornadoes predicted course you must determine the minimum time it would take to travel from your home located in district to the evacuation shelter located in district . Of course, once the tornado begins travelling down a bridge it becomes unstable disallowing its use; that is, if the tornado arrives at at time and is heading towards , the bidirectional bridge will no longer be safe to use at any time , even if you would nearly be finished crossing it.
Due to their size, residing in the same district as the tornado poses no threat.
입력
The first line of input will contain three integers, , , , indicating there are districts, ) bridges, and the tornadoes predicted course contains districts.
The next line of input contains two integers indicating the district of your home and the evacuation shelter respectively.
The following lines contain three integers each, , , , indicating there is a bidirectional bridge between districts and that takes time to cross. There will be at most one bridge between any pair of districts and for each bridge.
The final line contains space separated integers indicating the districts which the tornado is predicted to destroy. All bridges the tornado follows are guaranteed to exist, the tornado crosses each bridge in the same amount of time it would take for you to cross.
출력
Output a single integer indicating the minimum amount of time it will take to reach district from district while avoiding all unstable bridges. Output if it is impossible to reach from .