There are N cities in a country. There are M roads with parameters (L, R, W) denoting cities L and R that are connected and a road that was built between them for W$. Note that the roads are bidirectional in nature.
Now, a new policy is introduced to act that states the following:
Determine the amount of money that will be required for implementing the new policy?
Input format
Output format
For each test case, print a single line denoting the fund required according to the new policy.
Constraints
1≤T≤20000
1≤N,M≤200000
1≤L,R≤N
1≤W≤109
The sum of N and M over all test case do not exceed 200000.
First test case:
Maximum number of roads between any pair of towns is 3, which is between 1 and 2. So all the pairs of towns which have less than 3 roads will have their roads constrcuted. Towns 1 and 3 have a single road between them so it will be reconstructed and cost will be 4 and similarly 3 and 4 also have a single road between them and it will be reconstructed according to the new policy and cost will be 7.
Total cost: 4+7=11
Second test case:
This time cost is zero as maximum number of roads between any pair of town is 3, which is between 1 and 2. There are no roads other than that.