SKHOL - Sherlock Holmes

 

Sherlock Holmes is a renowned detective. His Scotland Yard colleagues often
provide him with a set of evidence and ask for his help in solving the
mysteries. After many years of practice, Holmes has gained an enormous
amount of experience and already knows causes for many common events,
which, combined with his extraordinary deductive capabilities, enables him to
solve cases in a matter of minutes, from the comfort of his chair.
Holmes' knowledge base can be modeled as a set of implications of the form
(where A and B represent events), which means that, if A occurred,
event B must have also occurred (remember that logical implication is false
only if A is tru

Sherlock Holmes is a renowned detective. His Scotland Yard colleagues often provide him with a set of evidence and ask for his help in solving the mysteries. After many years of practice, Holmes has gained an enormous amount of experience and already knows causes for many common events, which, combined with his extraordinary deductive capabilities, enables him to solve cases in a matter of minutes, from the comfort of his chair.

Holmes' knowledge base can be modeled as a set of implications of the form A -> B(where A and B represent events), which means that, if A occurred, event B must have also occurred (remember that logical implication is false

only if A is true and B is false). Of course, implications can form chains of reasoning, e.g. A -> B -> C. However, there will never be a circular chain of implications (e.g. A -> B -> ... -> A).

Holmes is given a set S = {S1, S2, S3, ..., Sn} of events that are known to have occurred. He can then, using his extensive knowledge and deductive powers, find all events that have certainly occurred.

It's important to note that Holmes' knowledge is so mind-bogglingly huge that he knows all possible causes of events. In other words, there is no implication that is true, but not included in Holmes' knowledge base.

Many detective agencies would highly appreciate Holmes' one of a kind capabilities, so you were given a task to accomplish with a computer what is out of reach for ordinary mortals. Write a program to find all events that have certainly occurred based on the given implications and evidence collected by your colleague detectives.

Input

First line of input consists of three integers, D (1 ≤ D ≤ 1000), the number of different types of events, M (1 ≤ M ≤ 100000), the number of implications, and N (1 ≤ N ≤ D), the number of evidence collected by the detectives.

Each of the M lines that follow contains two integers A and B (1 ≤ A, B ≤ D), describing an implication A -> B.

Finally, each of the last N lines contain an integer X (1 ≤ X ≤ D) describingan event that must have occurred, based on the evidence collected by detectives.

Output

The first and only line of output should contain integers (in any order) representing events that have certainly occurred.

Example

Input:
3 2 1
1 2
2 3
2

Output:
1 2 3 
Input:
3 2 1
1 3
2 3
3

Output:
3
Input:
4 4 1
1 2
1 3
2 4
3 4
4

Output:
1 2 3 4

Added by:Nhung anh sao dem
Date:2013-10-29
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:COCI 09/10 Contest #6

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.