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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Queue;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String input_str[] = new String[2];
			input_str = br.readLine().split("\\s+");
			int V = Integer.parseInt(input_str[0]);
			int E = Integer.parseInt(input_str[1]);

			Node nodes[] = new Node[V];
			for(int i = 0; i < V; i++)nodes[i] = new Node();

			int in_num[] = new int[V];
			for(int i = 0; i < V; i++)in_num[i] = 0;

			int from,to;
			StringBuilder ans = new StringBuilder();

			for(int loop = 0; loop < E; loop++){
				input_str = br.readLine().split("\\s+");
				from = Integer.parseInt(input_str[0]);
				to = Integer.parseInt(input_str[1]);
				in_num[to]++;
				nodes[from].list.add(to);
			}

			Queue<Integer> Q = new ArrayDeque<Integer>();
			for(int i = 0; i < V; i++){
				if(in_num[i] == 0){
					Q.add(i);
				}
			}

			int tmp,tmp2;

			while(!Q.isEmpty()){
				tmp = Q.peek();
				Q.poll();

				ans.append(Integer.toString(tmp)).append("\n");

				for(int i = 0; i < nodes[tmp].list.size(); i++){
					tmp2 = nodes[tmp].list.get(i);
					in_num[tmp2]--;
					if(in_num[tmp2] == 0){
						Q.add(tmp2);
					}
				}
			}
			System.out.print(ans.toString());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}

class Node{
	public ArrayList<Integer> list;

	Node(){
		list = new ArrayList<Integer>();
	}
}