Given an undirected graph with vertices and edges, tell whether every connected component is a clique, that is, if all the vertices of the component are directly connected to each other.
Input consists of several cases. Each case begins with and , followed by pairs , with , indicating an edge between and . Suppose , , that the vertices are numbered between 0 and , and that there are no repeated edges.
For each given graph, print “SI” if every connected
component is a clique, and “NO” otherwise.
Even if a green light is obtained, only solutions that perform a single graph traversal will receive the maximum score.
Input
6 4 0 1 2 1 2 0 3 5 6 6 0 5 1 2 2 3 3 4 4 1 2 4
Output
SI NO