Hobbit’s Resistor Graphs

Hobbit has only learnt the parallel and series method of calculating resistance across an electric network graph where there is a single resister on every edge of the undirected graph G. Given an undirected graph G, and 2 vertices u and v, if it is possible to calculate the resistance between u and v using only these 2 rules shown above, then the graph G is called series-parallel decomposible (spdecomposible for short) with respect to (u, v). In other words, G may be turned into just the 2 node graph of u, v connected by one edge, by a sequence of the following operations: (a) Replacement of a pair of parallel edges with a single edge that connects their common endpoints; (b) Replacement of a pair of edges incident to a vertex of degree 2 other than u or v with a single edge. Input The input contains multiple sets of data. The first line of each set contains 2 positive integers n (1 ≤ n ≤ 100000), and m (1 ≤ m ≤ 100000), which represent the number of nodes and the number of edges/resistors in the resistor network. Then, a total of m lines follows with each resister edge (u,v), such that (1 ≤ u, v ≤ n, u ̸= v). Output For each set of data, output on one line the number of unique pairs (u, v) with u < v, such that G is spdecomposible with respect to (u, v). Sample Input 66 12 13 14 23 24 56 Sample Output 6