E - Exciting tournament

Time limit: 2 s
Memory limit: 256 MiB
Languages: C, C++, Java, Python, ... (details)

Fito and his friends love Chess and they frequently play against each other. They numbered themselves from $1$ to $N$ (including Fito) in a convenient way. For some pairs of friends, $a_i$ and $b_i$ (with $a_i < b_i$), they already  know that $a_i$ always beats $b_i$. Also, if $a$ beats $b$ and $b$ beats $c$, it is implicitly known that $a$ beats $c$. This information is consistent, which means that player $a$ doesn´t beat him/herself (not even implicitly) and for every pair of players $a$ and $b$, either $a$ beats $b$, or $b$ beats $a$, or their expected match-result is not known.

All friends are now organizing a Chess tournament. Since there are too many participants, they want to split it into groups, in such a way that each group will play in a different room and all players in the same group will have to play against each other.

The tournament should be really exciting, therefore, no group can contain two players for which their expected match-result is known in advance (or implicitly), even if this means that there have to be some groups with a single player. To satisfy this condition, they computed the minimum number of rooms they would need, and it turns out that they are short by one. Therefore, they want to check if removing one player will solve the problem. More specifically, they want to know for each player if removing him or she will reduce the total number of rooms needed.


The first line of input contains two integers $N$ ($2 \leq N \leq 10^5$) the number of Fito's friends (including Fito), and $M$ ($1\leq M\leq 2*10^5$) the number of pairs of friends whose match-result is known in advance. The following $M$ lines will contain two integers $a_i,\ b_i$ ($1 \leq a_i,\ b_i \leq N$, $a_i < b_i$), which means that $a_i$ beats $b_i$.


Print in ascending order all the indices of the players such that when any of them is removed the number of rooms needed is decreased by $1$ at least. If there is no player that satisfies this condition, print $-1$ in a single line.

Sample test(s)

5 4 1 2 2 3 3 4 3 5
1 2 3
6 4 1 2 2 3 4 5 5 6