题目描述
Problem Description
In the JSOI world, there are $N$ distinct events (numbered from $1$ to $N$), and $M$ clues. Each clue corresponds to a tuple $(x, y)$, indicating that the occurrence of event $x$ will lead to the occurrence of event $y$.
Note: Clues are unidirectional, meaning that if event $y$ occurs, it does not necessarily mean event $x$ will occur.
Clues are transitive, meaning that if there are clues $(x, y)$ and $(y, z)$, then the occurrence of event $x$ will lead to the occurrence of event $z$.
Additionally, due to the rational nature of the world, no event $x$ will ever cause itself to occur through any sequence of clues.
Furthermore, the world only contains these $M$ clues, and we do not assume that events occur out of thin air (like Sherlock Holmes would never think that a bizarre murder was due to divine retribution). Specifically, for an event $x$, if $x$ occurs and there is an event that could cause $x$ to occur, then at least one such event must have occurred.
Given the $M$ clues in the world and $D$ events that have already occurred, which events can be definitively deduced to have occurred?
Input Format
The first line contains three integers separated by spaces: $N$, $M$, and $D$.
The next $M$ lines each contain two integers $x$ and $y$, representing the clue $(x, y)$, where $1 \leq x, y \leq N$.
The next $D$ lines each contain a distinct integer between $1$ and $N$, representing the known events that have occurred.
Output Format
Output a single line containing at least $D$ strictly increasing positive integers separated by spaces, representing the events that JYY can definitively deduce to have occurred based on the $M$ clues and $D$ known events.
Sample Input and Output
Sample Input #1
3 2 1
1 3
2 3
3
Sample Output #1
3
Sample Input #2
4 4 1
1 2
1 3
2 4
3 4
4
Sample Output #2
1 2 3 4
Notes
Sample Explanation
In the first sample, since either event $1$ or event $2$ occurring would lead to event $3$ occurring, we cannot determine which event actually occurred.
In the second sample, since event $4$ occurred, at least one of event $2$ or event $3$ must have occurred. Regardless of which one occurred, it can be deduced that event $1$ occurred.
Ultimately, since event $1$ occurred, we can deduce that all four events must have occurred.
Data Range
For $100\%$ of the data, $1 \leq D \leq N \leq 10^3, 1 \leq M \leq 10^5$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分