\problemname{Import Spaghetti}

\illustration{.4}{codereview.png}{cc-by NCPC~2017}%
%
You just graduated from programming school and nailed a Python programming job.
The first day at work you realize that you have inherited a mess.  The
\emph{spaghetti} design pattern was chosen by the previous maintainer, who
recently fled the country.
%
You try to make sense of the code, but immediately discover that different files
depend cyclically on each other.  Testing the code, in fact running the code,
has not yet been attempted.

As you sit down and think, you decide that the first thing to do is to eliminate
the cycles in the dependency graph.  So you start by finding a shortest
dependency cycle.

\section*{Input}
The first line of input contains a number $n$, $1 \le n \le 500$, the number of files.  Then follows one line with~$n$ distinct names of files.  Each name is a string with at least $1$ and at most $8$ lower case letters `\texttt{a}' to `\texttt{z}'.
%
Then follow~$n$ sections, one section per file name, in the order they were
given on the second line.  Each section starts with one line containing the name of the
file and an integer~$k$, followed by~$k$ lines, each starting with ``\texttt{import}''.

Each ``\texttt{import}'' line is a comma-space separated line of dependencies.  No file
imports the same file more than once, and every file imported is listed in the
second line of the input.  Comma-space separated means that every line will
start with ``\texttt{import}'', then have a list of file names separated by \texttt{``, ''} (see sample inputs for examples).  Each import statement is followed by at least one file name.



\section*{Output}

If the code base has no cyclic dependencies, output ``\texttt{SHIP
IT}''.  Otherwise, output a line containing the names of files in a
shortest cycle, in the order of the cycle (i.e., the $i$th file listed must import the $(i+1)$st file listed, and the last file listed must import the first).  If there are many shortest
cycles, any one will be accepted.
