Firework
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Alice and Bob get a strange firework accidentally, and they never know how to play it, so they come to you for help.

The firework consists of n nodes and n-1 fuses connecting pairs of nodes. The whole firework forms an undirected tree. At the time 0, several nodes are ignited simultaneously. After that, the fire begins to spread through the fuses to all directions from those nodes which has been ignited. When the fire reaches another node that haven't been ignited before, it will ignite the node and keep spreading.

Fire has a specific speed. If the fuse has the length L, it needs 2L seconds to conduct the fire. Then the question comes: how long it will take to burn up the firework? We consider that the firework is burned up if and only if all the fuses are burned up.

输入描述:

The first line contains two integers n, m  -- the number of nodes of the firework and the number of nodes which are ignited initially.

This is followed by n-1 lines with fuse descriptions. Each fuse is given by three integers u, v and w , meaning that there is a fuse between node u and v with the length w.

The next line contains m distinct integers describing the ignited nodes' numbers.

输出描述:

Only one line with a single number T --  the time it takes to burn up the firework.
示例1

输入

复制
3 2
1 2 1
2 3 2
1 3

输出

复制
3

说明

For the first example, the fire reaches node 2 from the fuse (1,2) in 2 seconds. But the fuse (2,3) is still burning, the final answer is 3 seconds.
示例2

输入

复制
5 2
1 2 5
2 3 1
2 4 2
4 5 1
1 4

输出

复制
7