
ZOJ Problem Set  3946
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 ith highway costs C_{i} dollars. It takes D_{i} minutes to travel between city X_{i} and Y_{i} on the ith highway. 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. InputThere 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}, Y_{i}, D_{i}, C_{i} (0 ≤ X_{i}, Y_{i} < N, 0 < D_{i}, C_{i} < 10^{5}). OutputFor 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. Sample Input2 4 5 0 3 1 1 0 1 1 1 0 2 10 10 2 1 1 1 2 3 1 2 4 5 0 3 1 1 0 1 1 1 0 2 10 10 2 1 2 1 2 3 1 2 Sample Output4 3 4 4 Author: LU, Yi Source: The 13th Zhejiang Provincial Collegiate Programming Contest 