Doomsday

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

문제

Doomsday is near! Or at least that’s what your brother is telling you. In his preparations he has constructed a clever network of well concealed food depots and water depots far out in a mountainous region. You are in your base, and the alarm goes off: how quickly can you fetch both food and water supplies?

입력

The first line contains four integers nn, mm, ww, ff, where 1n50,0001 \leq n \leq 50\\,000 is the number of hidden locations, 0m150,0000 \leq m \leq 150\\,000 is the number of trails in the network, 1wn1 \leq w \leq n is the number of water depots in total, and 1fn1 \leq f \leq n is the number of food depots in total. Your base is at location 00. The second line contains ww space-separated integers u_1,u_2,,u_wu\_1, u\_2, \ldots, u\_w, which represents the (distinct) locations of the water depots (0u_i<n0 \leq u\_i < n for each ii). The third line contains ff space-separated integers v_1,v_2,,v_fv\_1, v\_2, \ldots, v\_f, which represents the (distinct) locations of the food depots (0v_i<n0 \leq v\_i < n for each ii).

The next mm lines each describe a (bidirectional) trail in the network. The ithi^{\text{th}} such line contains three space-separated integers a_ia\_i, b_ib\_i and t_it\_i indicating that there is a trail between location a_ia\_i and b_ib\_i which takes t_it\_i hours to traverse (0a_i,b_i<n0 \leq a\_i, b\_i < n and 0t_i<1000 \leq t\_i < 100 for each ii).

출력

Output a single integer, the minimum number of hours required to fetch both food and water and bring it back to base.