406299: GYM102348 B Interesting Vertices

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Interesting Verticestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given a tree with $$$n$$$ vertices. A tree is a connected graph without any cycles. The vertices are indexed from $$$1$$$ to $$$n$$$.

$$$k$$$ vertices are colored (more specifically, the colored vertices have indices $$$a_1, a_2, \dots, a_k$$$). We can choose any uncolored vertex $$$x$$$ and root the tree at it, so we can assume that $$$x$$$ is the root of the tree. Let's analyze all the subtrees of the given tree such that the roots of these subtrees are the children of root vertex $$$x$$$. If each of these subtrees contains at least one colored vertex, then $$$x$$$ is an interesting vertex.

Your task is to find all interesting vertices in the given tree and print their indices in ascending order.

Input

The first line contains two integers $$$n$$$ and $$$k$$$ $$$(2 \le n \le 2 \cdot 10^{5}, 1 \le k < n)$$$ — the total number of vertices in the tree and the number of colored vertices, respectively.

The second line contains a sequence of distinct integers $$$a_1, a_2, \dots, a_k$$$ $$$(1 \le a_i \le n)$$$ — the indices of the colored vertices.

Next $$$n - 1$$$ lines denote the edge of the tree, each line contains two integers $$$u_j$$$ and $$$v_j$$$ $$$(1 \le u_j, v_j \le n, u_j \neq v_j)$$$ representing an edge between these two vertices. It is guaranteed that these edges form a tree.

Output

In the first line print $$$p$$$ — the number of interesting vertices.

In the second line print $$$p$$$ distinct integers — the indices of interesting vertices. Each interesting vertex should be printed exactly once. The indices should be sorted in ascending order.

ExamplesInput
4 1
3
1 2
2 3
2 4
Output
2
1 4 
Input
8 3
6 5 7
1 5
5 4
5 3
1 6
2 7
1 2
1 8
Output
4
2 3 4 8 
Note

In the first example there are three uncolored vertices, and only vertex $$$2$$$ is not an interesting vertex, since it is connected to three other vertices, but only one of these vertices contains a colored vertex in its subtree.

加入题单

算法标签: