14541454 SUSTech Online Judge
Problem 1454 --Leaves

1454: Leaves

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 635  Solved: 353
[Submit][Status][Web Board]


Given a tree whose nodes are numbered from 1 to \(n\). You are asked to print all the leaf nodes of the tree in ascending order. The root of the tree is node 1.


The first line contains one integer \(n\) \((1\le n \le 1\ 000\ 000)\), indicating the number of nodes in the tree.

Then \(n-1\) lines follow. Each line contains two integers \(u,v\) \((1 \le u, v \le n)\) describing an edge, indicating the indices of nodes which form an edge.


One line contains integers in ascending order.Multiple integers in one line must be separated by one space.

Sample Input

1 2
1 3
3 4

Sample Output

2 4