Cycle in an Undirected Graph
Determine whether an undirected simple graph contains a cycle.
Input
The first line contains n and m. The next m lines contain undirected edges.
1 <= n <= 1000
Output
Print 1 if a cycle exists; otherwise, print 0.
Example
Input
4 4
1 2
2 3
3 1
3 4
Output
1
Comments