Little Y is a clever girl, but she only knows how to calculate the resistance between two nodes using series and parallel methods.
Now, Little Y has a resistor network, and she wants to know how many pairs of nodes $(u, v)$ ($u \neq v$) have a resistance that can be calculated using series and parallel methods.
We formally define whether the resistance between a pair of nodes $(u, v)$ ($u \neq v$) can be calculated using series and parallel methods. First, we view the resistor network as a graph with $n$ nodes and $m$ edges (each resistor corresponds to an edge). Let $S$ be the set of all points that lie on any simple path (a path that does not visit any node more than once) from $u$ to $v$. That is, for a node $x$, if there exists a simple path from $u$ to $v$ that passes through $x$, then $x$ is in the set $S$. If $S$ is non-empty and the induced subgraph of $S$ is a two-terminal series-parallel graph with $u$ and $v$ as its terminals, then the resistance between $u$ and $v$ can be calculated using series and parallel methods.
A graph with two distinct terminals $s, t$ is called a two-terminal graph, where one is called the source and the other is called the sink. The parallel composition of two two-terminal graphs $X$ and $Y$ is a new graph formed by merging the sources of $X$ and $Y$ together and their sinks together. The series composition of two two-terminal graphs $X$ and $Y$ is a new graph formed by merging the sink of $X$ with the source of $Y$. A graph formed by a series of series-parallel operations starting from two-terminal graphs consisting of two nodes and one edge is called a two-terminal series-parallel graph.
The node set of the induced subgraph of $S$ is $S$, and the edge set consists of all edges from the original graph where both endpoints are in $S$.
Input
The first line contains two positive integers $n$ and $m$, representing the number of nodes and the number of resistors in the resistor network.
The next $m$ lines each contain two positive integers $u, v$ ($1 \le u, v \le n, u \neq v$), representing a resistor between node $u$ and node $v$.
Output
Output a single line containing the answer, which is the number of pairs of nodes whose resistance can be calculated using series and parallel methods.
Examples
Input 1
6 6 1 2 1 3 1 4 2 3 2 4 5 6
Output 1
6
Note 1
The feasible pairs are $(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (5, 6)$.
Input 2
13 18 1 2 2 3 2 4 3 4 3 5 4 5 5 6 5 7 5 8 6 8 7 8 8 9 10 11 10 12 10 13 11 12 11 13 12 13
Output 2
25
Input 3
See circuit/circuit_ex1.in and circuit/circuit_ex1.ans in the contestant directory.
Output 3
See circuit/circuit_ex1.in and circuit/circuit_ex1.ans in the contestant directory.
Input 4
See circuit/circuit_ex2.in and circuit/circuit_ex2.ans in the contestant directory.
Output 4
See circuit/circuit_ex2.in and circuit/circuit_ex2.ans in the contestant directory.
Constraints
Each test case satisfies the following conditions:
| Test Case | $n$ | $m$ | Constraints |
|---|---|---|---|
| 1 | $\le 10$ | $\le 10$ | The original graph is guaranteed to be connected, and there is no node whose removal disconnects the graph. |
| 2 | $\le 100$ | $\le 100$ | None |
| 3 | $\le 100$ | $\le 100$ | None |
| 4 | $\le 10^3$ | $\le 10^3$ | None |
| 5 | $\le 10^5$ | $\le 10^5$ | The original graph is guaranteed to be connected, and there is no node whose removal disconnects the graph. |
| 6 | $\le 10^5$ | $\le 10^5$ | The original graph is guaranteed to be connected, and there is no node whose removal disconnects the graph. |
| 7 | $\le 10^5$ | $\le 10^5$ | None |
| 8 | $\le 10^5$ | $\le 10^5$ | None |
| 9 | $\le 10^5$ | $\le 10^5$ | None |
| 10 | $\le 10^5$ | $\le 10^5$ | None |
Figure 1. Illustration of series and parallel compositions of two-terminal graphs.