Blazing New Trails

Choose a spanning tree of a graph whose edges each join a marked or unmarked vertex, with exactly w marked-unmarked edges, minimizing total cost.

Hard8Minimum spanning treeGraphSortingGreedyNo attempts yetTime limit2sMemory limit512 MB

Problem

Your state has just purchased a large, unspoiled tract of land and wants to turn it into a nature park with hiking trails. The land has nn places of interest that guests may want to hike to, and kk of them are special. The state wants to connect these places with hiking trails.

There are mm candidate trails. Each one directly connects two places of interest and has its own cost. The chosen trails must satisfy these constraints:

  1. There must be exactly one way to hike from any place to any other place.
  2. Exactly ww of the chosen trails must directly connect a special place with a regular place.

The state wants to minimize the total cost of blazing the trails. Find that minimum.

Input

The input consists of a single test case.

The first line contains four integers nn, mm, kk and ww, where nn (2n2×1052 \le n \le 2 \times 10^5) is the number of places, mm (1m5×1051 \le m \le 5 \times 10^5) is the number of candidate direct trails between places, kk (1k<n1 \le k < n) is the number of special places, and ww (1wn11 \le w \le n - 1) is the number of special-regular direct trails the state wants to blaze. The places are numbered 11 to nn.

Each of the next kk lines contains a single integer ss (1sn1 \le s \le n), the number of a special place. These values are distinct and given in ascending order.

Each of the next mm lines describes a candidate trail with three integers aa, bb and cc: the trail would connect places aa and bb (1a,bn1 \le a, b \le n, aba \ne b) and would cost cc (1c1051 \le c \le 10^5). No two places have more than one candidate trail between them, and a trail from aa to bb is the same as a trail from bb to aa.

Output

Print a single integer: the minimum total cost of blazing trails that satisfy the constraints, or 1-1 if it is not possible.