A forest is a graph without cycles, and each of its connected components is a tree. Given an undirected graph, is it a forest? In case it is, how many trees does it have?
Input consists of several graphs. Every graph starts with its number of vertices and its number of edges , followed by pairs indicating an edge between vertices and . Assume , , that vertices are numbered from to , and that there are neither repeated edges nor edges of the type .
For every graph, if it is a forest print the number of trees it has.
Otherwise, print “no”.
Input
1 0 2 1 1 0 2 0 4 3 0 1 1 2 0 2 8 6 0 4 5 3 3 1 3 7 2 4 6 0 8 6 0 1 2 1 3 4 4 5 5 3 7 6 10 9 0 1 0 2 1 3 1 4 2 5 2 6 3 7 3 8 3 9
Output
1 1 2 no 2 no 1