A magical tree with \(N\) vertices and \(N-1\) edges is provided to you. Each of the \(N-1\) edges have some positive weight. Assuming there are \(X\) edges in the simple path between vertices \(A\) and \(B\), then the separation between the vertices \(A\) and \(B\) can be determined using the following formula:
Now, the mystical value for each vertex is defined as the sum of the separation between this vertex & every other vertex. Your task is to determine the minimum mystical value that a vertex has in the given magical tree.
Note: A simple path is a path in a tree that does not have repeating vertices.
Input format
Output format
For each test case, print the minimum mystical value that a vertex has in the given magical tree in a new line.
Constraints
\(1 \leq T \leq 10^5 \\ 3 \leq N \leq 10^6 \\ 1≤u,v≤N\\ 1≤w≤10^6 \\ \text{The sum of all values of N over all test cases doesn't exceed } 10^6 \)
The first line denotes T = 1.
For test case \(1\):
We are given:
Now,
Since the minimum mystical value that a vertex has in the given magical tree is 19, the answer to this test case is 19.