{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\r\nEdward, 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.\r\n\u003c/p\u003e\r\n\r\n\u003cp\u003e\r\nThe Marjar Empire has \u003cvar\u003eN\u003c/var\u003e cities (including the capital), indexed from 0 to \u003cvar\u003eN\u003c/var\u003e - 1 (the capital is 0) and there are \u003cvar\u003eM\u003c/var\u003e highways can be built. Building the \u003cvar\u003ei\u003c/var\u003e-th highway costs \u003cvar\u003eC\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e dollars. It takes \u003cvar\u003eD\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e minutes to travel between city \u003cvar\u003eX\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e and \u003cvar\u003eY\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e on the \u003cvar\u003ei\u003c/var\u003e-th highway.\r\n\u003c/p\u003e\r\n\r\n\u003cp\u003e\r\nEdward 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 \u003cvar\u003ei\u003c/var\u003e (1 ≤ \u003cvar\u003ei\u003c/var\u003e ≤ \u003cvar\u003eN\u003c/var\u003e). Among all feasible plans, Edward wants to select the plan with minimal cost. Please help him to finish this task.\r\n\u003c/p\u003e\r\n\r\n\u003ch4\u003eInput\u003c/h4\u003e\r\n\r\n\u003cp\u003eThere are multiple test cases. The first line of input contains an integer \u003cvar\u003eT\u003c/var\u003e indicating the number of test cases. For each test case:\u003c/p\u003e\r\n\r\n\u003cp\u003e\r\nThe first contains two integers \u003cvar\u003eN\u003c/var\u003e, \u003cvar\u003eM\u003c/var\u003e (1 ≤ \u003cvar\u003eN\u003c/var\u003e, \u003cvar\u003eM\u003c/var\u003e ≤ 10\u003csup\u003e5\u003c/sup\u003e).\r\n\u003c/p\u003e\r\n\u003cp\u003e\r\nThen followed by \u003cvar\u003eM\u003c/var\u003e lines, each line contains four integers \u003cvar\u003eX\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e, \u003cvar\u003eY\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e, \u003cvar\u003eD\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e, \u003cvar\u003eC\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e (0 ≤ \u003cvar\u003eX\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e, \u003cvar\u003eY\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e \u0026lt; \u003cvar\u003eN\u003c/var\u003e, 0 \u0026lt; \u003cvar\u003eD\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e, \u003cvar\u003eC\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e \u0026lt; 10\u003csup\u003e5\u003c/sup\u003e).\r\n\u003c/p\u003e\r\n\r\n\u003ch4\u003eOutput\u003c/h4\u003e\r\n\r\n\u003cp\u003e\r\nFor 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.\r\n\u003c/p\u003e\r\n\r\n\u003ch4\u003eSample\u003c/h4\u003e\n\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\r\n2\r\n4 5\r\n0 3 1 1\r\n0 1 1 1\r\n0 2 10 10\r\n2 1 1 1\r\n2 3 1 2\r\n4 5\r\n0 3 1 1\r\n0 1 1 1\r\n0 2 10 10\r\n2 1 2 1\r\n2 3 1 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\r\n4 3\r\n4 4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n"}}]}