Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

K. Task processing

time limit per test

4 secondsmemory limit per test

512 megabytesinput

standard inputoutput

standard outputVasya wants to create a computing system to process arbitrary tasks. As a part of the system he needs an algorithm which will choose an order of task execution.

He came up with the following algorithm:

- There is a single execution queue. For task to be completed, it needs to be added to the queue.
- For each task two values are known:
*l*_{i}and*t*_{i}— the number of seconds that it takes to complete the task and the moment of time when this task is added to the execution queue. - If at some moment of time
*T*the algorithm has to select a task for execution, it picks the one with the minimum value of*l*_{i}- (*T*-*t*_{i})^{2}. In case of a tie, algorithm picks a task with the lowest index. Then for the following*l*_{i}seconds the algorithm will wait for the task to be completed.

In order to test the algorithm Vasya wants you to simulate it.

You are given *n* tasks. For each task, you know the number of seconds *l*_{i} that it takes to complete the task and the moment of time *t*_{i} when this task is added to the execution queue.

For each task find out the moment of time when it will be completed.

Input

The first line contains an integer number *n* (1 ≤ *n* ≤ 10^{5}) — the number of task to process. The next *n* lines contain two integers each: *l*_{i}, *t*_{i} (1 ≤ *l*_{i} ≤ 10^{5}, 0 ≤ *t*_{i} ≤ 10^{5}).

Output

Print *n* space-separated integers. The *i*-th integer is the moment of time when the *i*-th task was completed.

Examples

Input

1

10 5

Output

15

Input

3

3 0

4 3

5 2

Output

3 7 12

Input

3

3 0

4 2

5 1

Output

3 12 8

Input

6

3 0

5 1

4 2

5 18

4 19

5 14

Output

3 8 12 24 28 19

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Aug/17/2017 02:33:11 (c2).

Desktop version, switch to mobile version.

User lists

Name |
---|