{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv\u003e\u003cp\u003eThe cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and enjoy a vacation on the sunny shores of Lake Superior. Bessie, ever the competent travel agent, has named the Bullmoose Hotel on famed Cumberland Street as their vacation residence. This immense hotel has \u003ci\u003eN\u003c/i\u003e (1 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 50,000) rooms all located on the same side of an extremely long hallway (all the better to see the lake, of course).\u003c/p\u003e\u003cp\u003eThe cows and other visitors arrive in groups of size \u003ci\u003eD\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e (1 ≤ \u003ci\u003eD\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ N) and approach the front desk to check in. Each group \u003ci\u003ei\u003c/i\u003e requests a set of \u003ci\u003eD\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e contiguous rooms from Canmuu, the moose staffing the counter. He assigns them some set of consecutive room numbers \u003ci\u003er\u003c/i\u003e..\u003ci\u003er\u003c/i\u003e+\u003ci\u003eD\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e-1 if they are available or, if no contiguous set of rooms is available, politely suggests alternate lodging. Canmuu always chooses the value of \u003ci\u003er\u003c/i\u003e to be the smallest possible.\u003c/p\u003e\u003cp\u003eVisitors also depart the hotel from groups of contiguous rooms. Checkout \u003ci\u003ei\u003c/i\u003e has the parameters\u003ci\u003e X\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e and \u003ci\u003eD\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e which specify the vacating of rooms \u003ci\u003eX\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ..\u003ci\u003eX\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e +\u003ci\u003eD\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e-1 (1 ≤ \u003ci\u003eX\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ \u003ci\u003eN\u003c/i\u003e-\u003ci\u003eD\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e+1). Some (or all) of those rooms might be empty before the checkout.\u003c/p\u003e\u003cp\u003eYour job is to assist Canmuu by processing \u003ci\u003eM\u003c/i\u003e (1 ≤ \u003ci\u003eM\u003c/i\u003e \u0026lt; 50,000) checkin/checkout requests. The hotel is initially unoccupied.\u003c/p\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e* Line 1: Two space-separated integers: \u003ci\u003eN\u003c/i\u003e and \u003ci\u003eM\u003c/i\u003e\u003cbr\u003e* Lines 2..\u003ci\u003eM\u003c/i\u003e+1: Line \u003ci\u003ei\u003c/i\u003e+1 contains request expressed as one of two possible formats: (a) Two space separated integers representing a check-in request: 1 and \u003ci\u003eD\u003csub\u003ei \u003c/sub\u003e\u003c/i\u003e(b) Three space-separated integers representing a check-out: 2, \u003ci\u003eX\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e, and \u003ci\u003eD\u003csub\u003ei \u003c/sub\u003e\u003c/i\u003e\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e* Lines 1.....: For each check-in request, output a single line with a single integer \u003ci\u003er\u003c/i\u003e, the first room in the contiguous sequence of rooms to be occupied. If the request cannot be satisfied, output 0.\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\u003e10 6\r\n1 3\r\n1 3\r\n1 3\r\n1 3\r\n2 5 5\r\n1 6\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n4\r\n7\r\n0\r\n5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}