The machines again attacked the kingdom of Zion. The kingdom of Xions has N cities and N-1 bidirectional roads. The road network so that there is a unique path between any pair of cities.There is news in Morpheus that K Machines plan to destroy the entire kingdom. These machines originally live in K different cities of the kingdom, and at any time they can plan and launch an attack. Therefore, he asked Neo to destroy some of the roads in order to break the connection between the cars, after the destruction of these roads there should be no way between any two cars.
Since the attack can be at any time from now on, Neo must complete this task as quickly as possible. Each road in the kingdom takes a certain time to be destroyed, and they can be destroyed only one at a time.
You need to write a program that tells Neo the minimum amount of time it will require to break the connection between the machines.
Input Example The first line of input contains two integers, N and K, separated by spaces. Cities are numbered from 0 to N-1. Then follow the N-1 lines, each of which contains three integers separated by spaces, xyz, which means that there is a two-way road connecting city x and city y, and z units of time are required to destroy this road. Then K lines follow, each of which contains an integer. Ith integer is the identifier of the city where I am currently located in the car.
Output format Printing in one line the minimum time required to break the connection between machines.
Input example
5 3 2 1 8 1 0 5 2 4 5 1 3 4 2 4 0
Output result
10
Explanation Neo can destroy a road connecting city 2 and city 4 of weight 5, and a road connecting city 0 and city 1 of weight 5. As only one road can be destroyed at a time, the total minimum time is 10 time units. After the destruction of these roads, not one of the vehicles can reach another vehicle in any way.
Limitations
2 <= N <= 100,000 2 <= K <= N 1 <= time to destroy a road <= 1000,000
Can someone give an idea of ββhow to approach the solution.