Cycle in a Directed Graph


Submit solution

Points: 100
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

Determine whether a directed graph contains a directed cycle.

Input

The first line contains n and m. The next m lines contain directed edges.

  • 1 <= n <= 1000

Output

Print 1 if a directed cycle exists; otherwise, print 0.

Example

Input
4 4
1 2
2 3
3 1
3 4
Output
1

Comments

There are no comments at the moment.