import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  (n:m:_) <- fmap (map read . words) getLine :: IO [Int]
  abs <- replicateM (n-1+m) $ (\(a:b:_) -> (a,b)) . map read . words <$> getLine :: IO [(Int, Int)]
  putStrLn . unlines . map show $ solve n abs
  
solve :: Int -> [(Int, Int)] -> [Int]
solve n abs = map f [1..n]
  where
    adjList = toAdjList abs
    sorted = IntMap.fromList $ zip (topologocalSort adjList) [1..]
    revDirAdjList = reverseDirection adjList
    f :: Int -> Int
    f i | IntMap.notMember i revDirAdjList = 0
        | otherwise = if length candidates == 1
                      then head candidates
                      else maximumBy (\x y -> compare (sorted IntMap.! x) (sorted IntMap.! y)) candidates
          where
            candidates = revDirAdjList IntMap.! i 


type AdjList = IntMap.IntMap [Int]

toAdjList :: [(Int, Int)] -> AdjList
toAdjList = foldr insert IntMap.empty 
  where
    insert :: (Int, Int) -> AdjList -> AdjList
    insert (a, b) adjList = IntMap.insertWith (++) a [b] adjList

topologocalSort :: AdjList -> [Int]
topologocalSort as = reverse . dfs nodes [] IntSet.empty $ reverseDirection as
  where
    nodes = nub $ (IntMap.keys as) ++ join (IntMap.elems as)

dfs :: [Int] -> [Int] -> IntSet.IntSet -> AdjList -> [Int]
dfs [] visiteds _ _ = visiteds
dfs (s:ss) visiteds vset adjList
  | IntSet.member s vset = dfs ss visiteds vset adjList -- 訪問済のノード
  | IntMap.notMember s adjList = dfs ss (s:visiteds) newset adjList -- 入次数0のノード
  | null unvisiteds = dfs ss (s:visiteds) newset adjList -- 入字数0ではないが、上流が全て探索済みのノード
  | otherwise = dfs ((head unvisiteds):s:ss) visiteds vset adjList
    where
      unvisiteds = (adjList IntMap.! s) \\ visiteds
      newset = IntSet.insert s vset

-- Reverse direction of directed graph
reverseDirection :: AdjList -> AdjList
reverseDirection = IntMap.foldrWithKey f IntMap.empty
  where
    f :: Int -> [Int] -> AdjList -> AdjList
    f s gs adjList = foldr (\g al-> IntMap.insertWith (++) g [s] al) adjList gs 
  