AdvancedRating 1800
Safe Nodes
In a directed graph, a node is safe if every path from it ends at a node with no outgoing edges. Print the safe nodes in increasing order (or NONE).
Input
n m, then m lines 'u v'.
Output
One line.
Sample 1
Input
7 9 1 2 1 3 2 3 2 4 3 6 4 1 5 6 6 7 4 5
Output
3 5 6 7
Sample 2
Input
2 2 1 2 2 1
Output
NONE
Output appears here