Problem: <image>


A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can undertake task B after both task A and task B are finished. You can obtain the proper sequence of all the tasks by a topological sort.

Given a DAG $G$, print the order of vertices after the topological sort.

Constraints

* $1 \leq |V| \leq 10,000$
* $0 \leq |E| \leq 100,000$
* There are no parallel edges in $G$
* There are no self loops in $G$

Input

A directed graph $G$ is given in the following format:
$|V|\;|E|$
$s_0 \; t_0$
$s_1 \; t_1$
:
$s_{|E|-1} \; t_{|E|-1}$



$|V|$ is the number of vertices and $|E|$ is the number of edges in the graph. The graph vertices are named with the numbers $0, 1,..., |V|-1$ respectively.

$s_i$ and $t_i$ represent source and target nodes of $i$-th edge (directed).

Output

Print the vertices numbers in order. Print a number in a line.

If there are multiple possible solutions, print any one of them (the solution is judged by a special validator).

Example

Input

6 6
0 1
1 2
3 1
3 4
4 5
5 2


Output

0
3
1
4
5
2

Solution (in PYTHON3):

Solution:
# https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_4_B
# 仕組みは単純ゆえに、本では解説がバッサリ省略されている。操作の可視化を行うと図のようになる。
# ここでは隣接リストを用いて実装する。

from collections import deque
# 隣接リストはdefaultdictで管理すると楽です。
from collections import defaultdict
adj = defaultdict(lambda: [])

# input data
n_V, n_E = list(map(int, input().split()))
indeg = [0] * n_V  # 流入量管理
for _ in range(n_E):
    s, t = list(map(int, input().split()))
    indeg[t] += 1  # 流入量更新
    adj[s].append(t)


# Topological Sort by BFS
def topological_sort(dag, indeg):
    '''
    dag ... default dictで定義された隣接リスト(DAGを想定)
    indeg ... 各ノードについての流入量のリスト(inputのときについでにやったほうが計算量若干少なく済むでしょ？本質じゃないけど)
    '''
    is_visited = [False] * len(indeg)  # 訪問間利用
    ret = []  # グラフをソートしたあとに返す答え
    perm = [-1] * len(indeg)  # できる処理を一気にしようとしたときの順番

    que = deque()  # 各要素はノード, 処理回数
    for i, deg in enumerate(indeg):
        if deg == 0:
            que.append((i, 0))
            is_visited[i] = True

    while que:
        u, cnt = que.popleft()  # uは流入量0のノード
        ret.append(u)  # なので答えに加えていく
        perm[u] = cnt
        for to in dag[u]:  # uに隣接するノードtoについて深さ優先探索
            indeg[to] -= 1  # 隣接するノードは流入量を減らす
            if indeg[to] or is_visited[to]:
                continue  # 流入待ちか訪問済みだったら飛ばす
            que.append((to, cnt + 1))  # 次の訪問候補に追加
            is_visited[to] = True

    if False in is_visited:
        print(is_visited)
        raise ValueError('inputted graph is not DAG')

    return ret, perm


ans, _ = topological_sort(adj, indeg)
print(*ans, sep='\n')