import sys



def I(): return int(sys.stdin.readline())

def MI(): return list(map(int, sys.stdin.readline().split()))

def LMI(): return list(map(int, sys.stdin.readline().split()))

MOD = 10 ** 9 + 7

INF = float('inf')





N, M = MI()



nl = [list() for _ in range(N + 1)]

rev = [list() for _ in range(N + 1)]

deg = [0 for _ in range(N + 1)]

for _ in range(N - 1 + M):

    A, B = MI()

    nl[A].append(B)

    rev[B].append(A)

    deg[B] += 1



for i, l in enumerate(deg):

    if i > 0 and l == 0:

        root = i

        break



stack = [root]

tsorted = list()

while len(stack) > 0:

    v = stack.pop()

    tsorted.append(v)

    for next_v in nl[v]:

        deg[next_v] -= 1

        if deg[next_v] == 0:

            stack.append(next_v)



ans = [0] * (N + 1)

p = {root: 0}

for v in tsorted:

    ans[v] = p[v]

    for next_v in nl[v]:

        p[next_v] = v

for a in ans[1:]:

    print(a)
import sys



def I(): return int(sys.stdin.readline())

def MI(): return list(map(int, sys.stdin.readline().split()))

def LMI(): return list(map(int, sys.stdin.readline().split()))

MOD = 10 ** 9 + 7

INF = float('inf')





# トポロジカルソート

# deg[i] := 頂点iの入次数

# returns := トポロジカルソートされた頂点番号のリスト

def tsort(deg, nl):

    tsorted = list()

    stack = [i for i, x in enumerate(deg) if x == 0]

    while len(stack) > 0:

        v = stack.pop()

        tsorted.append(v)

        for next_v in nl[v]:

            deg[next_v] -= 1

            if deg[next_v] == 0:

                stack.append(next_v)

    return tsorted





N, M = MI()



nl = [list() for _ in range(N)]

deg = [0 for _ in range(N)]

for _ in range(N - 1 + M):

    A, B = MI()

    A, B = A - 1, B - 1

    nl[A].append(B)

    deg[B] += 1



tsorted = tsort(deg, nl)



ans = [0] * N

p = {tsorted[0]: -1}

for v in tsorted:

    ans[v] = p[v]

    for next_v in nl[v]:

        p[next_v] = v

for a in ans:

    print((a + 1))
import sys


def I():
    return int(sys.stdin.readline())


def MI():
    return list(map(int, sys.stdin.readline().split()))


def LMI():
    return list(map(int, sys.stdin.readline().split()))


MOD = 10**9 + 7
INF = float("inf")
N, M = MI()
nl = [list() for _ in range(N + 1)]
rev = [list() for _ in range(N + 1)]
deg = [0 for _ in range(N + 1)]
for _ in range(N - 1 + M):
    A, B = MI()
    nl[A].append(B)
    rev[B].append(A)
    deg[B] += 1
for i, l in enumerate(deg):
    if i > 0 and l == 0:
        root = i
        break
stack = [root]
tsorted = list()
while len(stack) > 0:
    v = stack.pop()
    tsorted.append(v)
    for next_v in nl[v]:
        deg[next_v] -= 1
        if deg[next_v] == 0:
            stack.append(next_v)
ans = [0] * (N + 1)
p = {root: 0}
for v in tsorted:
    ans[v] = p[v]
    for next_v in nl[v]:
        p[next_v] = v
for a in ans[1:]:
    print(a)

import sys


def I():
    return int(sys.stdin.readline())


def MI():
    return list(map(int, sys.stdin.readline().split()))


def LMI():
    return list(map(int, sys.stdin.readline().split()))


MOD = 10**9 + 7
INF = float("inf")
# トポロジカルソート
# deg[i] := 頂点iの入次数
# returns := トポロジカルソートされた頂点番号のリスト
def tsort(deg, nl):
    tsorted = list()
    stack = [i for i, x in enumerate(deg) if x == 0]
    while len(stack) > 0:
        v = stack.pop()
        tsorted.append(v)
        for next_v in nl[v]:
            deg[next_v] -= 1
            if deg[next_v] == 0:
                stack.append(next_v)
    return tsorted


N, M = MI()
nl = [list() for _ in range(N)]
deg = [0 for _ in range(N)]
for _ in range(N - 1 + M):
    A, B = MI()
    A, B = A - 1, B - 1
    nl[A].append(B)
    deg[B] += 1
tsorted = tsort(deg, nl)
ans = [0] * N
p = {tsorted[0]: -1}
for v in tsorted:
    ans[v] = p[v]
    for next_v in nl[v]:
        p[next_v] = v
for a in ans:
    print((a + 1))

+# トポロジカルソート +# deg[i] := 頂点iの入次数 +# returns := トポロジカルソートされた頂点番号のリスト +def tsort(deg, nl): +    tsorted = list() +    stack = [i for i, x in enumerate(deg) if x == 0] +    while len(stack) > 0: +        v = stack.pop() +        tsorted.append(v) +        for next_v in nl[v]: +            deg[next_v] -= 1 +            if deg[next_v] == 0: +                stack.append(next_v) +    return tsorted + + -nl = [list() for _ in range(N + 1)] -rev = [list() for _ in range(N + 1)] -deg = [0 for _ in range(N + 1)] +nl = [list() for _ in range(N)] +deg = [0 for _ in range(N)] +    A, B = A - 1, B - 1 -    rev[B].append(A) -for i, l in enumerate(deg): -    if i > 0 and l == 0: -        root = i -        break -stack = [root] -tsorted = list() -while len(stack) > 0: -    v = stack.pop() -    tsorted.append(v) -    for next_v in nl[v]: -        deg[next_v] -= 1 -        if deg[next_v] == 0: -            stack.append(next_v) -ans = [0] * (N + 1) -p = {root: 0} +tsorted = tsort(deg, nl) +ans = [0] * N +p = {tsorted[0]: -1} -for a in ans[1:]: -    print(a) +for a in ans: +    print((a + 1))