{"raw_statement":[{"iden":"statement","content":"Polycarp starts his own business. Tomorrow will be the first working day of his car repair shop. For now the car repair shop is very small and only one car can be repaired at a given time.\n\nPolycarp is good at marketing, so he has already collected _n_ requests from clients. The requests are numbered from 1 to _n_ in order they came.\n\nThe _i_\\-th request is characterized by two values: _s__i_ — the day when a client wants to start the repair of his car, _d__i_ — duration (in days) to repair the car. The days are enumerated from 1, the first day is tomorrow, the second day is the day after tomorrow and so on.\n\nPolycarp is making schedule by processing requests in the order from the first to the _n_\\-th request. He schedules the _i_\\-th request as follows:\n\n*   If the car repair shop is idle for _d__i_ days starting from _s__i_ (_s__i_, _s__i_ + 1, ..., _s__i_ + _d__i_ - 1), then these days are used to repair a car of the _i_\\-th client.\n*   Otherwise, Polycarp finds the first day _x_ (from 1 and further) that there are _d__i_ subsequent days when no repair is scheduled starting from _x_. In other words he chooses the smallest positive _x_ that all days _x_, _x_ + 1, ..., _x_ + _d__i_ - 1 are not scheduled for repair of any car. So, the car of the _i_\\-th client will be repaired in the range \\[_x_, _x_ + _d__i_ - 1\\]. It is possible that the day _x_ when repair is scheduled to start will be less than _s__i_.\n\nGiven _n_ requests, you are asked to help Polycarp schedule all of them according to the rules above."},{"iden":"input","content":"The first line contains integer _n_ (1 ≤ _n_ ≤ 200) — the number of requests from clients.\n\nThe following _n_ lines contain requests, one request per line. The _i_\\-th request is given as the pair of integers _s__i_, _d__i_ (1 ≤ _s__i_ ≤ 109, 1 ≤ _d__i_ ≤ 5·106), where _s__i_ is the preferred time to start repairing the _i_\\-th car, _d__i_ is the number of days to repair the _i_\\-th car.\n\nThe requests should be processed in the order they are given in the input."},{"iden":"output","content":"Print _n_ lines. The _i_\\-th line should contain two integers — the start day to repair the _i_\\-th car and the finish day to repair the _i_\\-th car."},{"iden":"examples","content":"Input\n\n3\n9 2\n7 3\n2 4\n\nOutput\n\n9 10\n1 3\n4 7\n\nInput\n\n4\n1000000000 1000000\n1000000000 1000000\n100000000 1000000\n1000000000 1000000\n\nOutput\n\n1000000000 1000999999\n1 1000000\n100000000 100999999\n1000001 2000000"}],"translated_statement":[{"iden":"statement","content":"Polycarp 开始了自己的生意。明天将是他的汽车修理店的第一个营业日。目前，这家汽车修理店规模很小，同一时间只能修理一辆车。\n\nPolycarp 擅长营销，因此他已经收集了 #cf_span[n] 个客户的请求。这些请求按到达顺序编号为 #cf_span[1] 到 #cf_span[n]。\n\n第 #cf_span[i] 个请求由两个值描述：#cf_span[si] — 客户希望开始修理其汽车的日期，#cf_span[di] — 修理该车所需的天数。日期从 1 开始编号，第一天是明天，第二天是后天，依此类推。\n\nPolycarp 按照从第 1 个到第 #cf_span[n] 个请求的顺序处理请求来制定排程。他为第 #cf_span[i] 个请求安排如下：\n\n给定 #cf_span[n] 个请求，请你帮助 Polycarp 根据上述规则为所有请求安排排程。\n\n第一行包含整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 200]) —— 客户请求的数量。\n\n接下来的 #cf_span[n] 行每行包含一个请求。第 #cf_span[i] 个请求由一对整数 #cf_span[si, di] 给出 (#cf_span[1 ≤ si ≤ 109], #cf_span[1 ≤ di ≤ 5·106])，其中 #cf_span[si] 是修理第 #cf_span[i] 辆车的期望开始时间，#cf_span[di] 是修理第 #cf_span[i] 辆车所需的天数。\n\n请求应按照输入中给出的顺序处理。\n\n请输出 #cf_span[n] 行。第 #cf_span[i] 行应包含两个整数 —— 修理第 #cf_span[i] 辆车的开始日期和结束日期。"},{"iden":"input","content":"第一行包含整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 200]) —— 客户请求的数量。接下来的 #cf_span[n] 行每行包含一个请求。第 #cf_span[i] 个请求由一对整数 #cf_span[si, di] 给出 (#cf_span[1 ≤ si ≤ 109], #cf_span[1 ≤ di ≤ 5·106])，其中 #cf_span[si] 是修理第 #cf_span[i] 辆车的期望开始时间，#cf_span[di] 是修理第 #cf_span[i] 辆车所需的天数。请求应按照输入中给出的顺序处理。"},{"iden":"output","content":"请输出 #cf_span[n] 行。第 #cf_span[i] 行应包含两个整数 —— 修理第 #cf_span[i] 辆车的开始日期和结束日期。"},{"iden":"examples","content":"输入\n3\n9 2\n7 3\n2 4\n输出\n9 10\n1 3\n4 7\n\n输入\n4\n1000000000 1000000\n1000000000 1000000\n100000000 1000000\n1000000000 1000000\n输出\n1000000000 1000999999\n1 1000000\n100000000 100999999\n1000001 2000000"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of requests.  \nLet $ R = \\{(s_i, d_i) \\mid i \\in \\{1, \\dots, n\\}\\} $ be the sequence of requests, where:  \n- $ s_i \\in \\mathbb{Z}^+ $ is the preferred start day of request $ i $,  \n- $ d_i \\in \\mathbb{Z}^+ $ is the duration (in days) of request $ i $.  \n\nLet $ (a_i, b_i) \\in \\mathbb{Z}^+ \\times \\mathbb{Z}^+ $ denote the actual start and finish days for request $ i $, where $ b_i = a_i + d_i - 1 $.\n\n**Constraints**  \n1. $ 1 \\leq n \\leq 200 $  \n2. $ 1 \\leq s_i \\leq 10^9 $  \n3. $ 1 \\leq d_i \\leq 5 \\cdot 10^6 $\n\n**Objective**  \nSchedule requests in order $ i = 1 $ to $ n $, such that:  \n- $ a_1 = s_1 $  \n- For $ i \\geq 2 $:  \n  $$\n  a_i = \\max(s_i, b_{i-1} + 1)\n  $$  \n- $ b_i = a_i + d_i - 1 $\n\nOutput the pair $ (a_i, b_i) $ for each $ i \\in \\{1, \\dots, n\\} $.","simple_statement":null,"has_page_source":false}