let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let cs = Array.make n [] in
  let ps = 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);
      ps.(b - 1) <- a - 1 :: ps.(b - 1)
  done;
  let dp = Array.make n None in
  let rec visit u =
    List.iter (fun v ->
      if dp.(v) = None then begin
        dp.(v) <- Some u;
        visit v
      end) cs.(u) in
  let rec solve v =
    visit v;
    dp.(v) <- None;
    match List.find (fun u -> dp.(u) = None) ps.(v) with
    | exception Not_found -> ()
    | u -> solve u in
  solve 0;
  Array.iter (fun o ->
    Printf.printf "%d\n" @@
    match o with None -> 0 | Some v -> v + 1) dp
