Animals are waiting in a line, in a quarantine zone, before they can enter a hunting-free area, where they will find an easier life.
When entering the quarantine zone, animals have to check in with a guard. The guard writes down the animal species, and then the animal is allowed to join the end of the line, in the last position. At the other end of the line, animals have to check out: when the animal in the first position in the line is finally allowed to enter the hunting-free area, another guard writes down the animal species. Thus, each guard maintains a list of animal species, written down in the chronological order in which the animals have checked in or out. A total of $N$ animals, representing $S$ species, have checked in (and, therefore, checked out).
However, animals may enter the waiting line and leave it in different orders. Indeed, some animal species are friends with each other, and thus two animals from such species, if they occupy adjacent places in the line may accept to switch their places.
You have a list of those pairs of animal species that may accept to switch their places when being in adjacent positions in the line: this list contains L pairs. You were handed out the check-in list maintained by the first guard. Depending on which animals decided to switch places, several check-out lists might be possible. Among all those possible lists, which one comes first in alphabetical order?
The input consists of the following lines:
*Limits*
The output should contain a single line containing $N$ words $w_0, \\dots, w_{N -1}$, separated by spaces: the list $w_0, \\dots, w_{N -1}$ must be, among all the possible check-out lists, the one that comes first in alphabetical order.
*Sample Explanation*
The six possible orderings at check-out, sorted in (increasing) alphabetical order, are:
## Input
The input consists of the following lines: Line 1 contains three space-separated integers $S$, $L$ and $N$. $S$ is the number of animal species, $L$ is the number of pairs of species that are friends with each other, and $N$ is the number of animals that entered the waiting line. Line $i + 2$, for $0 <= i < S$, contains the name of one of the represented species: this name is made of a single word, with uppercase letters between "A" and "Z", and contains between 1 and 20 letters. Line $i + S + 2$, for $0 <= i < L$, contains two space-separated species names $A$ and $B$ describing that $A$ and $B$ are friends with each other. Line $S + L + 2$ represents the check-in list, and it contains $N$ space-separated species names: for all $1 <= k <= N$, the $k$th word is the name of the species of the animal that entered the line in $k$th position. *Limits* $1 <= S <= 200$; $0 <= L <= 10000$; $1 <= N <= 100000$.
## Output
The output should contain a single line containing $N$ words $w_0, \\dots, w_{N -1}$, separated by spaces: the list $w_0, \\dots, w_{N -1}$ must be, among all the possible check-out lists, the one that comes first in alphabetical order.
[samples]
## Note
*Sample Explanation*The six possible orderings at check-out, sorted in (increasing) alphabetical order, are: ANT ANTILOPE CAT CAT CAT ANT ANT CAT ANTILOPE CAT CAT ANT ANT CAT CAT ANTILOPE CAT ANT ANT CAT CAT CAT ANT ANTILOPE ANT CAT CAT CAT ANTILOPE ANT ANTILOPE ANT CAT CAT CAT ANT
**Definitions**
Let $ t \in \mathbb{Z} $ be the number of test cases.
For each test case:
- Let $ n \in \mathbb{Z} $ be the number of planets, labeled $ 0 $ to $ n-1 $.
- Let $ m \in \mathbb{Z} $ be the number of directed routes.
- Let $ V \in \mathbb{Z}_{\geq 0} $ be the fuel capacity (Delta V limit).
- Let $ s_i \in \mathbb{Z}_{\geq 0} $ be the science collected upon visiting planet $ i $, for $ i \in \{0, 1, \dots, n-1\} $.
- Let $ G = (V, E) $ be a directed acyclic graph (DAG), where $ V = \{0, 1, \dots, n-1\} $, and each edge $ (a, b) \in E $ has weight $ c_{a,b} \in \mathbb{Z}_{>0} $, representing the Delta V cost to travel from planet $ a $ to planet $ b $.
- The graph is guaranteed to have a unique source at planet $ 0 $, and there exists a path from planet $ 0 $ to every other planet.
**Constraints**
1. $ 1 \leq t \leq 1000 $
2. $ 1 \leq n \leq 6000 $, $ 0 \leq m \leq 12000 $, $ 0 \leq V \leq 6000 $
3. $ \sum n \leq 6000 $, $ \sum m \leq 12000 $ across all test cases
4. $ 0 \leq s_i \leq 10^9 $, $ 1 \leq c_{a,b} \leq 10^9 $
5. $ G $ is a DAG with no cycles; all paths start at planet $ 0 $.
**Objective**
Find the maximum total science collectible starting from planet $ 0 $, subject to the constraint that the total Delta V cost of the path does not exceed $ V $. Formally:
$$
\max_{P \in \mathcal{P}} \sum_{i \in P} s_i
$$
where $ \mathcal{P} $ is the set of all simple paths in $ G $ starting at planet $ 0 $, and for each path $ P $, the total cost $ \sum_{(a,b) \in P} c_{a,b} \leq V $.