Problems
Topological Sort
Topological Sort
Given a directed unweighted graph. Topologically sort its vertices.
\InputFile
The first line contains the number of vertices $n~(1 \le n \le 10^5)$ and the number of edges $m~(1 \le m \le 10^5)$ in a graph. In the following $m$ lines, the edges of the graph are listed, each of which is defined by a pair of numbers --- the indices of the starting and ending vertices.
\OutputFile
Print any topological sort of the graph as a sequence of vertex numbers. If the graph cannot be topologically sorted, then print $-1$.
\includegraphics{https://static.e-olymp.com/content/c8/c892750f0f88eb3a20f84a3344f54f2268287c3f.gif}
Input example #1
6 6 1 2 3 2 4 2 2 5 6 5 4 6
Output example #1
4 6 3 1 2 5