{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eYou’ve finally got mad at “the world’s most stupid” employees of yours and decided to do some firings. You’re now simply too mad to give response to questions like “Don’t you think it is an even more stupid decision to have signed them?”, yet calm enough to consider the potential profit and loss from firing a good portion of them. While getting rid of an employee will save your wage and bonus expenditure on him, termination of a contract before expiration costs you funds for compensation. If you fire an employee, you also fire all his underlings and the underlings of his underlings and those underlings’ underlings’ underlings… An employee may serve in several departments and his (direct or indirect) underlings in one department may be his boss in another department. Is your firing plan ready now?\u003c/p\u003e\u003c/span\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eThe input starts with two integers \u003ci\u003en\u003c/i\u003e (0 \u0026lt; \u003ci\u003en\u003c/i\u003e ≤ 5000) and \u003ci\u003em\u003c/i\u003e (0 ≤ \u003ci\u003em\u003c/i\u003e ≤ 60000) on the same line. Next follows \u003ci\u003en\u003c/i\u003e + \u003ci\u003em\u003c/i\u003e lines. The first \u003ci\u003en\u003c/i\u003e lines of these give the net profit/loss from firing the \u003ci\u003ei\u003c/i\u003e-th employee individually \u003ci\u003eb\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e (|\u003ci\u003eb\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e| ≤ 10\u003csup\u003e7\u003c/sup\u003e, 1 ≤ \u003ci\u003ei\u003c/i\u003e ≤ \u003ci\u003en\u003c/i\u003e). The remaining \u003ci\u003em\u003c/i\u003e lines each contain two integers \u003ci\u003ei\u003c/i\u003e and \u003ci\u003ej\u003c/i\u003e (1 ≤ \u003ci\u003ei\u003c/i\u003e, \u003ci\u003ej\u003c/i\u003e ≤ \u003ci\u003en\u003c/i\u003e) meaning the \u003ci\u003ei\u003c/i\u003e-th employee has the \u003ci\u003ej\u003c/i\u003e-th employee as his direct underling.\u003c/p\u003e\u003c/span\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eOutput two integers separated by a single space: the minimum number of employees to fire to achieve the maximum profit, and the maximum profit.\u003c/p\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\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\u003e5 5\r\n8\r\n-9\r\n-20\r\n12\r\n-10\r\n1 2\r\n2 5\r\n1 4\r\n3 4\r\n4 5\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2 2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"As of the situation described by the sample input, firing employees 4 and 5 will produce a net profit of 2, which is maximum."}}]}