CSES - Cities
  • Time limit: 2.00 s
  • Memory limit: 256 MB

There are nn cities in Byteland, and kk of them are important cities frequently visited by the king of Byteland.

There are also mm roads in the country, each of them connecting two cities. Unfortunately, the condition of the roads is so bad that the king cannot drive through them at full speed with his sports car.

For each road, the cost for renovating it is known. Your task is to choose which roads will be renovated so that all kk important cities are connected with renovated roads, and the total cost is as low as possible.

Input

The first input line contains three integers nn, kk and mm: the number of cities, the number of important cities and the number of roads. The cities are numbered 1,2,,n1,2,\ldots,n. The second input line contains kk integers: the important cities.

Finally, the input contains mm lines that describe the roads. Each line contains three integers aa, bb and cc, meaning that there is a bidirectional road between cities aa and bb, and the renovation cost for the road is cc.

You may assume that there is a route between any two cities.

Output

You should output the minimum total cost for renovating the roads so that the king can travel between all important cities with his sports car.

Example

Input:

4 3 6
1 3 4
1 2 4
1 3 9
1 4 6
2 3 2
2 4 5
3 4 8

Output:

11

Subtasks

In all subtasks 1c1091 \le c \le 10^9 and nkn \ge k.

Subtask 1 (22 points)

  • 2k52 \le k \le 5
  • n20n \le 20
  • 1m401 \le m \le 40

Subtask 2 (14 points)

  • 2k32 \le k \le 3
  • n105n \le 10^5
  • 1m21051 \le m \le 2 \cdot 10^5

Subtask 3 (15 points)

  • 2k42 \le k \le 4
  • n1000n \le 1000
  • 1m20001 \le m \le 2000

Subtask 4 (23 points)

  • k=4k=4
  • n105n \le 10^5
  • 1m21051 \le m \le 2 \cdot 10^5

Subtask 5 (26 points)

  • k=5k=5
  • n105n \le 10^5
  • 1m21051 \le m \le 2 \cdot 10^5