Grey inherited the gallery at the ink district of Scriptoria along with its curious bookkeeping system for roads. Time to make sense of it. Task: Print YES if the directed graph contains a cycle, otherwise NO. Input format: First line: n and m. Next m lines: u v (directed). Output format: Print YES or NO. Constraints: 1 <= n <= 2322; 0 <= m <= 2322.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= n <= 2322; 0 <= m <= 2322.
