LearnPy Hub
← Arena
IntermediateRating 1400

Is There a Loop?

Print YES if the undirected graph contains a cycle (no repeated edges or self-loops are given).

Input

n m, then m lines 'u v'.

Output

YES or NO.

Sample 1

Input
3 3
1 2
2 3
3 1
Output
YES

Sample 2

Input
4 3
1 2
2 3
3 4
Output
NO
solution.py
Output appears here
Is There a Loop? · Python Arena problem · LearnPy Hub