import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B

import           Control.Monad.ST
import           Data.Array.IArray
import           Data.Array.MArray
import           Data.Array.ST
import           Data.List
import           Data.STRef

readi :: B.ByteString -> Int
readi b | Just (n, _) <- B.readInt b = n

solve :: Array Int [Int] -> [Int]
solve graph = runST $ do
    prenum <- newArray (0, v) (-1)
    parent <- newArray (0, v) (-1)
    lowest <- newArray (0, v) (-1)
    visited <- newArray (0, v) False
    timer <- newSTRef 1
    dfs graph prenum parent lowest visited timer 0 (-1)

    np <- newSTRef 0
    ret <- newSTRef []
    forM_ [1 .. v] $ \i -> do
        p <- readArray parent i
        if p == 0
            then modifySTRef' np (+ 1)
            else do
                pp <- readArray prenum p
                li <- readArray lowest i
                when (pp <= li) $ modifySTRef' ret (p :)

    npv <- readSTRef np
    when (npv > 1) $ modifySTRef' ret (0 :)

    readSTRef ret
  where
    (_, v) = bounds graph

dfs :: Array Int [Int]
    -> STUArray s Int Int
    -> STUArray s Int Int
    -> STUArray s Int Int
    -> STUArray s Int Bool
    -> STRef s Int
    -> Int
    -> Int
    -> ST s ()
dfs graph prenum parent lowest visited timer current prev = do
    t <- readSTRef timer
    modifySTRef' timer (+ 1)
    writeArray prenum current t
    writeArray lowest current t

    writeArray visited current True

    forM_ (graph ! current) $ \next -> do
        isVisited <- readArray visited next
        case () of
            _ | not isVisited -> do
                writeArray parent next current
                dfs graph prenum parent lowest visited timer next current
                lc <- readArray lowest current
                ln <- readArray lowest next
                writeArray lowest current (min lc ln)
              | next /= prev -> do
                lc <- readArray lowest current
                ln <- readArray prenum next
                writeArray lowest current (min lc ln)
              | otherwise -> return ()

main :: IO ()
main = do
    [v, e] <- fmap readi . B.words <$> B.getLine
    xs <- fmap concat . replicateM e $ do
        [a, b] <- fmap readi . B.words <$> B.getLine
        return [(a, b), (b, a)]
    let graph = accumArray (flip (:)) [] (0, v-1) xs
    mapM_ print (sort $ solve graph)

