{"trustable":false,"sections":[{"title":"","value":{"format":"MD","content":"\u003cp\u003eFJ\u0027s \u003ci\u003eN\u003c/i\u003e (1 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 10,000) cows conveniently indexed 1..\u003ci\u003eN\u003c/i\u003e are standing in a line. Each cow has a positive integer height (which is a bit of secret). You are told only the height \u003ci\u003eH\u003c/i\u003e (1 ≤ \u003ci\u003eH\u003c/i\u003e ≤ 1,000,000) of the tallest cow along with the index \u003ci\u003eI\u003c/i\u003e of that cow.\u003c/p\u003e\u003cp\u003eFJ has made a list of \u003ci\u003eR \u003c/i\u003e(0 ≤ \u003ci\u003eR\u003c/i\u003e ≤ 10,000) lines of the form \"cow 17 sees cow 34\". This means that cow 34 is at least as tall as cow 17, and that every cow between 17 and 34 has a height that is strictly smaller than that of cow 17.\u003c/p\u003e\u003cp\u003eFor each cow from 1..\u003ci\u003eN\u003c/i\u003e, determine its maximum possible height, such that all of the information given is still correct. It is guaranteed that it is possible to satisfy all the constraints.\u003c/p\u003e"}},{"title":"Input","value":{"format":"MD","content":"Line 1: Four space-separated integers: \u003ci\u003eN\u003c/i\u003e, \u003ci\u003eI\u003c/i\u003e, \u003ci\u003eH\u003c/i\u003e and \u003ci\u003eR\u003c/i\u003e\n\u003cbr\u003eLines 2..\u003ci\u003eR\u003c/i\u003e+1: Two distinct space-separated integers \u003ci\u003eA\u003c/i\u003e and \u003ci\u003eB\u003c/i\u003e (1 ≤ \u003ci\u003eA\u003c/i\u003e, \u003ci\u003eB\u003c/i\u003e ≤ \u003ci\u003eN\u003c/i\u003e), indicating that cow \u003ci\u003eA\u003c/i\u003e can see cow \u003ci\u003eB\u003c/i\u003e."}},{"title":"Output","value":{"format":"MD","content":"Lines 1..\u003ci\u003eN\u003c/i\u003e: Line \u003ci\u003ei\u003c/i\u003e contains the maximum possible height of cow \u003ci\u003ei\u003c/i\u003e."}},{"title":"Sample","value":{"format":"MD","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\u003e9 3 5 5\n1 3\n5 3\n4 3\n3 7\n9 8\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\n4\n5\n3\n4\n4\n5\n5\n5\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}