There are several test cases.
Each case starts with two integers n and m in a line. n stands for the number of all villages, m stands for the number of villages the government has chosen.( 0 < n < 1000, 0 < m <= n)
Then follow m integers in a line which means the chosen villages.
Then n - 1 lines follow, each line contains three integers a, b, c, indicating that between a and b there is a road available which costs c. (1 <= a, b <= n, a! = b, c <= 2000)