Problem F: Minimal Time

Problem F: Minimal Time

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 1541  Solved: 222
[Submit][Status][Web Board]


There are \(n\) cities numbered from \(1\) to \(n\), and \(n-1\) roads connecting these \(n\) cities, i.e., it is a tree with \(n\) nodes. Each road takes \(1\) day for people to travel through. There are \(k\) people who initially stay in different \(k\) cities. They decide to meet in the same city as soon as possible. Please find the minimal time needed.


The first line will be an integer \(T\) \((1≤T≤10)\), which is the number of test cases.

For each test data, the first line contains two integers \(n\) and \(k\) \((1\leq n\leq 100\ 000, 1\leq k\leq n)\) — the number of cities and the number of friends.

Then there are \(n - 1\) lines. Each line contains two integers \(A\) and \(B\), which means there is a road between city \(A\) and city \(B\).

Then there is a line contains \(k\) integers, the \(i-th\) integer \(p_i\) indicates the place they initially stay.


\(T\) lines. For each case, one integer in one line for the minimal time to meet.

Sample Input

4 2
1 2
2 4
2 3
1 3

Sample Output