| VI UnBalloon Contest Mirror |
|---|
| Finished |
Isa, wanting to join the climbing group Climbing Camels, decided to start climbing mountains. In order to be accepted as a climbing camel, Isa must climb all the available $$$N$$$ mountains. However, for Isa to be allowed to climb the mountain of a certain level, she must have climbed other easier mountains first.
Your mission is: given the number of mountains and pairs of mountains $$$(A, B)$$$ where mountain of level $$$A$$$ must be climbed before mountain of level $$$B$$$ determine the lexicographically smallest order in which Isa can climb all the mountains and become a climbing camel.
An order $$$A$$$ is lexicographically smaller than another order $$$B$$$ if there exists an $$$i$$$ such that $$$A_i \lt B_i$$$ and for all $$$j$$$ with $$$1 \leq j \lt i$$$, $$$A_j = B_j$$$.
The first line contains two integers $$$N$$$ and $$$M$$$ $$$(1 \leq N, M \leq 2 \cdot 10^5)$$$.
In each of the next $$$M$$$ lines, two integers $$$A$$$ and $$$B$$$ $$$(1 \leq A \lt B \leq N)$$$ are given, where in order to climb the mountain of level $$$B$$$, Isa must first have climbed the mountain of level $$$A$$$. Certainly $$$A \lt B$$$, because a lower difficulty level is easier to climb .
Print $$$N$$$ numbers representing the lexicographically smallest order that Isa must follow to become a climbing camel, or $$$-1$$$ if there is no existing order that allows Isa to climb all the mountains.
3 21 22 3
1 2 3
5 11 5
1 2 3 4 5
| Name |
|---|


