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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""

input:
6 6
0 1
1 2
3 1
3 4
4 5
5 2

output:
0
3
1
4
5
2
"""

from sys import stdin
from collections import deque

UNVISITED, VISITED_IN_QUEUE, POPPED_OUT = 0, 1, 2


def generate_adj_matrix(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
        init_in_deg_list[v_to] += 1
    return init_adj_table, init_in_deg_list


def topological_sort():
    for v in range(vertices):
        if not in_deg_list[v] and status[v] is UNVISITED:
            bfs(v)
    return ans


def bfs(v):
    queue = deque()

    queue.append(v)
    status[v] = VISITED_IN_QUEUE

    while queue:
        current = queue.popleft()
        ans.append(current)

        for v_adj in adj_table[current]:
            in_deg_list[v_adj] -= 1
            if not in_deg_list[v_adj] and status[v_adj] is UNVISITED:
                status[v_adj] = VISITED_IN_QUEUE
                queue.appendleft(v_adj)

        status[current] = POPPED_OUT

    return None


if __name__ == '__main__':
    _input = stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])

    status = [UNVISITED] * vertices
    init_adj_table = tuple([] for _ in range(vertices))
    init_in_deg_list = [0] * vertices

    ans = []
    adj_table, in_deg_list = generate_adj_matrix(v_info)
    print(*topological_sort(), sep='\n')