Write a program that, given an undirected graph, tells if we can paint all vertices with only two colors, in such a way that no two neighboring vertices have the same color.
Input consists of several cases, each with the number of vertices and the number of edges , followed by pairs indicating an edge between and . Suppose , , that vertices are numbered from 0 to , , and that there is no more than one edge between any pair .
For every case, print “yes” if the graph is
two-colorable, and “no” otherwise.
Input
2 1 0 1 4 3 1 2 3 2 3 1 1 0 4 2 0 3 2 1
Output
yes no yes yes