using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            int m = cin.ReadInt;
            Graph graph = new Graph();

            for (int i = 0; i < n + m - 1; i++)
            {
                graph.edges.Add(new Edge(cin.ReadInt - 1, cin.ReadInt - 1));
            }

            graph.init(n);

            int parent = -1;
            for (int i = 0; i < n; i++)
            {
                Node node = graph.nodes[i];
                if (node.inRank == 0)
                {
                    parent = i;
                }
            }

            int[] ans = new int[n];
            Queue<int> queue = new Queue<int>();

            ans[parent] = 0;
            queue.Enqueue(parent);

            while (queue.Count > 0)
            {
                int now = queue.Dequeue();

                foreach (int outEdge in graph.nodes[now].outEdges)
                {
                    graph.nodes[outEdge].inRank--;

                    if (graph.nodes[outEdge].inRank == 0)
                    {
                        ans[outEdge] = now + 1;
                        queue.Enqueue(outEdge);
                    }
                }
            }

            Console.WriteLine(String.Join("\n", ans));
        }

        public class Graph
        {
            public List<Node> nodes { get; set; }
            public List<Edge> edges { get; set; }

            public Graph()
            {
                this.nodes = new List<Node>();
                this.edges = new List<Edge>();
            }

            public Graph(List<Edge> edges)
            {
                this.nodes = new List<Node>();
                this.edges = edges;
            }

            public void init(int n)
            {
                for (int i = 0; i < n; i++)
                {
                    this.nodes.Add(new Node());
                }

                foreach (Edge e in edges)
                {
                    this.nodes[e.from].outEdges.Add(e.to);
                    this.nodes[e.to].inRank++;
                }
            }
        }

        public class Node
        {
            public int inRank { get; set; }
            public List<int> outEdges { get; set; }

            public Node()
            {
                this.inRank = 0;
                this.outEdges = new List<int>();
            }
        }

        public class Edge
        {
            public int from { get; set; }
            public int to { get; set; }

            public Edge(int from, int to)
            {
                this.from = from;
                this.to = to;
            }
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}

Measured memory_bytes: 39876