The smallest Topological Sort
Medium
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given a directed unweighted graph. Find its lexicographically smallest topological sorting.
Input
The first line contains two integers and — the number of vertices and edges in the graph. The next lines describe the edges of the graph. Each edge is given by a pair of integers — the starting and ending vertices.
Output
Print the lexicographically smallest topological sorting of the graph as a sequence of vertex numbers. If it is not possible to perform a topological sorting, print .
Examples
Input #1
Answer #1
Submissions 866
Acceptance rate 44%