import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
 
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
 
 
def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD
 
 
def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD
 
 
def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret
 
 
def solve():
    n, m = getList()
    iri = [0 for i in range(n)]
    ki = [[] for i in range(n)]
 
    for i in range(n + m - 1):
        a, b = getZList()
        iri[b] += 1
        ki[a].append(b)
 
    root = -1
    for i, ir in enumerate(iri):
        if ir == 0:
            root = i
            break
 
    depth = [0 for i in range(n)]
    oya = [-1 for i in range(n)]
    visited = [0 for i in range(n)]
    visited[root] = 1
    d = deque()
    d.append(root)
    while(d):
        cur = d.pop()
        cd = depth[cur]
        for nx in ki[cur]:
            if depth[nx] < cd + 1:
                depth[nx] = cd + 1
                oya[nx] = cur
 
            if not visited[nx]:
                d.append(nx)
 
            visited[nx] = 1
 
    for oy in oya:
        print(oy + 1)
 
 
 
def main():
    n = getN()
    for _ in range(n):
        solve()
 
 
if __name__ == "__main__":
    # main()
    solve()
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret


def solve():
    n, m = getList()
    iri = [0 for i in range(n)]
    ki = [[] for i in range(n)]

    for i in range(n + m - 1):
        a, b = getZList()
        iri[b] += 1
        ki[a].append(b)

    root = -1
    for i, ir in enumerate(iri):
        if ir == 0:
            root = i
            break

    depth = [0 for i in range(n)]
    oya = [-1 for i in range(n)]
    visited = [0 for i in range(n)]
    visited[root] = 1
    d = deque()
    d.append(root)
    while(d):
        cur = d.popleft()
        cd = depth[cur]
        for nx in ki[cur]:
            if depth[nx] < cd + 1:
                depth[nx] = cd + 1
                oya[nx] = cur

            if not visited[nx]:
                d.append(nx)

            visited[nx] = 1

    for oy in oya:
        print(oy + 1)



def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()


### FIXED CODE ###

def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

n,m = getNM()
children = [[] for i in range(n+2)]
n_in = [0] * (n+1)
par_origin = [0] * (n+1)

#入力の処理
for i in range(n+m-1):
    a,b = getNM()
    children[a].append(b)
    n_in[b] += 1

#根を見つける
for i in range(1,n+m-1):
    if n_in[i]:
        pass
    else:
        root = i
        break

#次数を減らしながら探索
import queue
def bfs(root):
    q = queue.Queue()
    q.put(root)
    while(True):
        try:
            cur = q.get(block=False)
        except:
            break
        for c in children[cur]:
            if n_in[c] == 1:
                par_origin[c] = cur
                q.put(c)
            else:
                n_in[c] -= 1

bfs(root)
for i in range(1, n+1):
    print(par_origin[i])