#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

## Problem Description

Gug is going visiting! In the town that Gug lives in, there are a total of *N* houses and *N* - 1 roads, and each road *i* connects houses *A _{i}* and

*B*, taking

_{i}*C*minutes to travel in either direction. It is guaranteed that it is possible to travel from each house to another directly or indirectly using these roads.

_{i}
Gug needs to visit a total of *K* of these houses. The *i*th house that Gug needs to visit is house *V _{i}*, and Gug needs to visit all the houses in some order during the day. At the start of the day, Gug can choose any house to start at, and then must travel from house to house such that he reaches all the houses that he needs to visit at least once. Assuming it takes a negligible amount of time for Gug to do the actual visiting, and Gug can end the day at any house, what is the minimum amount of time required for Gug to complete his visits?

## Input

The first line of input will contain two integers, *N* and *K*.

The second line of input will contain *K* integers, representing the array *V*. *V* will not contain any number twice.

The next *N* - 1 lines of input will contain three integers each, *A _{i}*,

*B*and

_{i}*C*.

_{i}## Output

The output should contain one integer, the minimum amount of time, in minutes, Gug needs to complete his visiting.

## Limits

For all subtasks: 1 ≤ C_{i} ≤ 10^{9}, 0 ≤ A_{i}, B_{i}, V_{i} < N.

Subtask 1 (17%): 2 ≤ K ≤ N ≤ 8.

Subtask 2 (20%): 2 ≤ K ≤ N ≤ 1000.

Subtask 3 (15%): 2 ≤ N ≤ 200000, K = 2.

Subtask 4 (22%): 2 ≤ K = N ≤ 200000.

Subtask 5 (26%): 2 ≤ K ≤ N ≤ 200000.

Subtask 6 (0%): Sample Testcases.

## Sample Input 1

7 3 4 0 6 0 2 4 2 4 3 4 5 2 2 1 1 1 3 5 1 6 2

## Sample Output 1

13

## Explanation

Gug visits 0, 4 then 6.

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 17 | 21 | 1s | 256MB | Minimum |

2 | 20 | 41 | 1s | 256MB | Minimum |

3 | 15 | 20 | 1s | 256MB | Minimum |

4 | 22 | 20 | 1s | 256MB | Minimum |

5 | 26 | 101 | 1s | 256MB | Minimum |

6 | 0 | 1 | 1s | 256MB | Minimum |

### Judge Compile Command

g++-8 ans.cpp -o visiting -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512