Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus, he proposed the highway project.

The Marjar Empire has `N` cities (including the capital), indexed from 0 to `N` - 1 (the capital is 0) and there are `M` highways can be built. Building the `i`-th highway costs `C _{i}` dollars. It takes

Edward wants to find a construction plan with minimal total time needed to reach other cities from the capital, i.e. the sum of minimal time needed to travel from the capital to city `i` (1 ≤ `i` ≤ `N`). Among all feasible plans, Edward wants to select the plan with minimal cost. Please help him to finish this task.

There are multiple test cases. The first line of input contains an integer `T` indicating the number of test cases. For each test case:

The first contains two integers `N`, `M` (1 ≤ `N`, `M` ≤ 10^{5}).

Then followed by `M` lines, each line contains four integers `X _{i}`,

For each test case, output two integers indicating the minimal total time and the minimal cost for the highway project when the total time is minimized.

提交代码