eolymp
bolt
Try our new interface for solving problems
Problems

Distance Sum

Distance Sum

You are given a connected undirected unweighted graph. The distance d(u, v) between two vertices u and v is defined as the number of edges in the shortest path between them. Find the sum of d(u, v) over all unordered pairs (u, v).

Input

The first line contains two integers n and m (2n105, n - 1mn + 42) — the number of vertices and the number of edges in the graph respectively. The vertices are numbered from 1 to n.

Each of the following m lines contains two integers xi and yi (1xi, yin, xiyi) - the endpoints of the i-th edge.

There is at most one edge between every pair of vertices.

Output

Output a single integer — the sum of the distances between all unordered pairs of vertices in the graph.

Explanation

In the first example the distance between four pairs of vertices connected by an edge is equal to 1 and d(1, 4) = d(2, 4) = 2.

Time limit 1 second
Memory limit 128 MiB
Input example #1
4 4
1 2
2 3
3 1
3 4
Output example #1
8
Input example #2
7 10
1 2
2 6
5 3
5 4
5 7
3 6
1 7
5 1
7 4
4 1
Output example #2
34
Source 2018 ACM NEERC, Semifinals, December 2, Problem D