Given an undirected graph , where is a set of vertices and is a set of edges, a connected component of is a maximal connected subgraph of . In other words, every two vertices and of belong to the same connected component if and only if there is a path from to . In the example below there are 7 connected components.
Given two undirected (sub)graphs and , and are said to be isomorphic if and only if there exists a bijection such that for every , . In the example above, the connected component with vertices is isomorphic to exactly two connected components: those with vertices and .
Write a program such that, for every given undirected graph , computes the number of pairs (not counting order) of connected components of that are isomorphic. For instance, the result for the graph above is 4: with , with , with , and with .
Input consists of several graph descriptions. Each one begins with the number of vertices and the number of edges . Follow pairs of different numbers, each between 0 and . You can assume . No edges are repeated. Every given connected component has at most 6 vertices.
For every graph, print the number of connected components that are pairwise isomorphic.
Input
16 10 5 2 5 9 12 8 14 11 14 3 0 13 6 10 6 1 15 8 11 3 101 0
Output
4 5050