Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

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

D. Event Dates

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputOn a history lesson the teacher asked Vasya to name the dates when *n* famous events took place. He doesn't remembers the exact dates but he remembers a segment of days [*l*_{i}, *r*_{i}] (inclusive) on which the event could have taken place. However Vasya also remembers that there was at most one event in one day. Help him choose such *n* dates of famous events that will fulfill both conditions. It is guaranteed that it is possible.

Input

The first line contains one integer *n* (1 ≤ *n* ≤ 100) — the number of known events. Then follow *n* lines containing two integers *l*_{i} and *r*_{i} each (1 ≤ *l*_{i} ≤ *r*_{i} ≤ 10^{7}) — the earliest acceptable date and the latest acceptable date of the *i*-th event.

Output

Print *n* numbers — the dates on which the events took place. If there are several solutions, print any of them. It is guaranteed that a solution exists.

Examples

Input

3

1 2

2 3

3 4

Output

1 2 3

Input

2

1 3

1 3

Output

1 2

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Nov/21/2017 16:45:50 (c4).

Desktop version, switch to mobile version.

User lists

Name |
---|