Score : $400$ points
Among the sequences $P$ that are permutations of $(1, 2, \dots, N)$ and satisfy the condition below, find the lexicographically smallest sequence.
If there is no such $P$, print -1
.
Input is given from Standard Input in the following format:
$N$ $M$ $A_1$ $B_1$ $\vdots$ $A_M$ $B_M$
Print the answer.
4 3 2 1 3 4 2 4
2 1 3 4
The following five permutations $P$ satisfy the condition: $(2, 1, 3, 4), (2, 3, 1, 4), (2, 3, 4, 1), (3, 2, 1, 4), (3, 2, 4, 1)$. The lexicographically smallest among them is $(2, 1, 3, 4)$.
2 3 1 2 1 2 2 1
-1
No permutations $P$ satisfy the condition.