AdvancedRating 1500
Course Order
Course pairs 'a b' mean a must be taken before b. Print an order of all courses 1..n (always choose the smallest available course next), or IMPOSSIBLE if there's a cycle.
Input
n m, then m lines 'a b'.
Output
One line.
Sample 1
Input
4 3 1 2 1 3 3 4
Output
1 2 3 4
Sample 2
Input
2 2 1 2 2 1
Output
IMPOSSIBLE
Output appears here