import FGL
import DFS
import Graph
import GraphData
import GraphTools
import IO

import CPUTime

-- Just for test
import Random
import List

readNum :: IO Int
readNum = do { line <- getLine; readIO line }

myShowList [] = []
myShowList (x:xs) = (show x) ++ "\n" ++ (myShowList xs)

main = do { 
            numNodes <- readNum;
            -- theGraph <- do { bla <- readGraph; return $! bla };
            theGraph <- return $! ucycle numNodes;
            timeStart <- getCPUTime;
            putStr $ myShowList $ dfs [1] theGraph;
            timeEnd <- getCPUTime;
            hPutStr stderr (show ((fromIntegral (timeEnd-timeStart))/1.0e12) ++ " seconds\n")
          }
