{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eThere are \u003cb\u003en\u003c/b\u003e preemptive jobs to be processed on a single machine. Each job \u003ci\u003ej\u003c/i\u003e has a processing time \u003cb\u003ep\u003csub\u003ej\u003c/sub\u003e\u003c/b\u003e and deadline \u003cb\u003ed\u003csub\u003ej\u003c/sub\u003e\u003c/b\u003e. Preemptive constrains are specified by oriented graph without cycles. Arc (\u003ci\u003ei,j\u003c/i\u003e) in this graph means that job \u003ci\u003ei\u003c/i\u003e has to be processed before job \u003ci\u003ej\u003c/i\u003e. A solution is specified by a sequence of the jobs. For any solution the completion time \u003cb\u003eC\u003csub\u003ej\u003c/sub\u003e\u003c/b\u003e is easily determined. \u003c/p\u003e\u003cp\u003eThe objective is to find the optimal solution in order to minimize\u003c/p\u003e\u003cp style\u003d\"padding-left: 2em;\"\u003emax{\u003cb\u003eC\u003csub\u003ej\u003c/sub\u003e\u003c/b\u003e-\u003cb\u003ed\u003csub\u003ej\u003c/sub\u003e\u003c/b\u003e, 0}.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains a single integer \u003cb\u003en\u003c/b\u003e, 1 ≤ \u003cb\u003en\u003c/b\u003e ≤ 50000. Each of the next \u003cb\u003en\u003c/b\u003e lines contains two integers \u003cb\u003ep\u003csub\u003ej\u003c/sub\u003e\u003c/b\u003e and \u003cb\u003ed\u003csub\u003ej\u003c/sub\u003e\u003c/b\u003e, 0 ≤ \u003cb\u003ep\u003csub\u003ej\u003c/sub\u003e\u003c/b\u003e ≤ 1000, 0 ≤ \u003cb\u003ed\u003csub\u003ej\u003c/sub\u003e\u003c/b\u003e ≤ 1000000, separated by one or more spaces. Line \u003cb\u003en\u003c/b\u003e+2 contains an integer \u003cb\u003em\u003c/b\u003e (number of arcs), 0 ≤ \u003cb\u003em\u003c/b\u003e ≤ 10*\u003cb\u003en\u003c/b\u003e. Each of the next \u003cb\u003em\u003c/b\u003e lines contains two integers \u003ci\u003ei\u003c/i\u003e and \u003ci\u003ej\u003c/i\u003e, 1 ≤ \u003ci\u003ei\u003c/i\u003e, \u003ci\u003ej\u003c/i\u003e ≤ n.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eEach of the \u003cb\u003en\u003c/b\u003e lines contains integer i (number of job in the optimal sequence).\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\u003e2\r\n4 1\r\n4 0\r\n1\r\n1 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}