Write a program that, given a directed graph, determines whether the graph has any cycle or not.
Input
Input consists of several cases. Every case begins with the number of vertices n and the number of arcs m. Follow m pairs u, v, indicating that there is an arc u → v, where u ≠ v. Assume 1 ≤ n ≤ 104, 0 ≤ m ≤ 5n, and that for every pair of vertices u and v there is at most one arc of the kind u → v. Vertices are numbered from 0 to n−1.
Output
For every case, print “yes” or “no” depending on whether the graph has any cycle or not.
Input
3 2 0 1 1 2 3 3 0 1 1 2 2 0 4 5 2 3 1 3 3 0 0 2 0 1 5 6 0 1 0 2 0 3 1 3 2 3 4 1
Output
no yes yes no