The judges of NWRRC came up with $n$ problems on a similar topic and decided to use them for $n$ consecutive years, one problem per year. The only question was: in what order should they be used?

Each problem's name consists of two words. Let's call two names \textit{similar} if either their first words are the same or their second words are the same. For example, \texttt{eight shaped} and \texttt{eight connected} are similar, while \texttt{hello world} and \texttt{world hello} are not.

The judges decided to implement the following rule: in the first year, they chose a problem arbitrarily. In~every subsequent year, if there was a problem with a name similar to the previous year's problem that was still unused, they chose one of such problems; otherwise, they chose any unused problem.

You are given the names of the problems in chronological order of their use. Determine whether the judges correctly followed the rule above, or if they made a mistake.