A factory has
The twist: a circular dependency may be hidden across several tasks.
The first line contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the number of tasks and dependency rules.
Each of the next KaTeX can only parse string typed expression lines contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression, meaning task KaTeX can only parse string typed expression must be completed before task KaTeX can only parse string typed expression.
Print KaTeX can only parse string typed expression if all tasks can be completed, otherwise print KaTeX can only parse string typed expression.
Input
5 4
1 2
1 3
3 4
2 5OutputYESExplanationOne valid order is KaTeX can only parse string typed expression.
Example 2:
Input
3 3
1 2
2 3
3 1OutputNOExplanationThe tasks depend on each other in a cycle.