import Control.Applicative

main = interact $ unlines . map show' . kagisys . read' . lines
 where
  read' (n:xs) = let (reg,(_:uids)) = splitAt (read n) xs in (reg,uids)
  show' (stats,uid) = case stats of
  Nothing -> "Unknown "++ uid
   (Just True) -> "Opened by " ++ uid
   (Just False) -> "Closed by " ++ uid

kagisys (reg,uids) = transit (Just False) uids
 where
  transit _ [] = []
  transit stats (u:uids)
   | elem u reg = (not <$> stats, u) : transit (not <$> stats) uids
   | otherwise = (Nothing, u) : transit stats uids