Skip to content
UPEEC

Is There a Loop?

Medium#graphs#union-find#dfs· solved by 0 · time limit 2.0 s

Does the undirected graph contain a cycle? (No self-loops or repeated edges.) Print Yes or No.

Input

nn and mm, then mm lines u v.

Output

Yes or No.

Constraints

1≤n≤1051 \le n \le 10^5, 0≤m≤2×1050 \le m \le 2 \times 10^5

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

Sign in or join free to run and submit your solution.