let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let cs = Array.make n [] in
  for i = 1 to n - 1 + m do
    Scanf.scanf "%d %d\n" @@ fun a b -> cs.(a - 1) <- b - 1 :: cs.(a - 1)
  done;
  let p = ref 0 in
  let dp = Array.make n None in
  for i = 0 to n - 1 do
    let rec visit u =
      List.iter (fun v ->
        let b = dp.(v) = None in
        dp.(v) <- Some u;
        if b then visit v) cs.(u) in
    if dp.(i) = None then (visit i; p := i)
  done;
  dp.(!p) <- None;
  Array.iter (fun o ->
    Printf.printf "%d\n" @@
    match o with None -> 0 | Some v -> v + 1) dp
