module Main where
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
import Data.Graph
import Control.Monad
import Data.List(sortOn, foldl')
import qualified Data.Array.IO as MV
import qualified Data.Array as A

readIntPair :: B.ByteString -> (Int,Int)
readIntPair s = p
    where
    Just p = do
        (n1, s') <- B.readInt s
        (n2, _ ) <- B.readInt (B.tail s')
        return (n1,n2)

main :: IO ()
main = do
    (n,m) <- fmap readIntPair B.getLine 
    es <- fmap (map readIntPair . B.lines) B.getContents
    let g = buildG (1,n) es
        vs = topSort g
    par <- MV.newArray (1,n) 0 :: IO (MV.IOUArray Int Int)
    forM_ vs $ \v -> do
        let cs = g A.! v 
        forM_ cs $ \w ->
            MV.writeArray par w v
    ps <- MV.getElems par
    putStr $ unlines $ map show ps
