Longest Shortest Paths at Shymbulak

Count every shortest path between all vertex pairs at the maximum distance in a connected graph with N vertices and N equal edges.

Hard8GraphBFSTreeTwo pointersNo attempts yetTime limit2sMemory limit256 MB

Problem

The Shymbulak resort has NN places that tourists visit, and NN roads of equal length connect them. Every road is bidirectional. From any place you can reach every other place, but some pairs of places are separated by a great many roads.

Before the administration builds new roads, it wants to know how many shortest paths run between the pairs of places that lie farthest apart.

The distance between two places is the number of roads on a shortest path between them. A pair of places lies farthest apart when this distance is the largest over all pairs. Find every pair whose distance is the largest, then add up the number of shortest paths of each such pair.

Input

The first line contains an integer NN (3N2000003 \le N \le 200000). Each of the next NN lines contains the numbers of the two places that one road connects. Place numbers are between 11 and NN. No pair of places is connected by two roads.

Output

Print one integer, the total number of shortest paths over all pairs of places that lie farthest apart.

Note

When one pair has several shortest paths of the same length, count all of them. A pair joined by two different shortest paths adds 22 to the answer.