vrsta (COCI CONTEST_#4)
Time limit: 1 seconds | Memory limit: 512 MB | Task type: batch
Algorithms: order statistics, binary indexed tree, coordinate compression

# Task Vrsta

Domagoj's favorite school subject is P.E. Every P.E. class starts with warm-up exercises. The teacher has an interesting way of choosing the student who will lead the warm-up. The students stand in a line sorted by their height. The teacher will choose the student that is standing in the middle of the line. If two students are in the middle, he will choose the shorter one. For example: if the students have heights 1 3 5 7 11, the student with height 5 will lead the warm-up exercises.

Domagoj does not remember how tall his classmates are. Luckily, next to him stands Lovro who is very good at estimating people's heights. He gives Domagoj *n* statements: \"There are *a<sub>i</sub>* students entering the gym with height *v<sub>i</sub>*\". After every statement said by Lovro, Domagoj is interested in the height of the student who will lead the warm-up, if only the students who entered the gym come to P.E. class. Help him answer his questions!

## Input

The first line contains the integer *n* (1 ≤ *n* ≤ 200000), the number of Lovro's statements.

The following *n* lines contain two integers *v<sub>i</sub>* , *a<sub>i</sub>* (1 ≤ *v<sub>i</sub> , a<sub>i</sub>* ≤ 10<sup>9</sup> ), the height and the number of students in Lovro's statement.

## Output

In the *i*-th of *n* lines output the answer to Domagoj's question after *i* of Lovro's statements.

## Scoring

| Subtask | Points | Constraints                 |
|---------|--------|-----------------------------|
| 1       | 19     | $n, v_i \leq 1000$          |
| 2       | 26     | $a_1 = a_2 = ... = a_n = 1$ |
| 3       | 29     | $v_1 < v_2 < ... < v_n$     |
| 4       | 36     | No additional constraints   |

## Examples

| input | input | input |
|---|---|---|
| 3 | 4 | 3 |
| 2 1 | 17 2 | 10 20 |
| 3 1 | 23 5 | 100 5 |
| 1 1 | 11 4 | 1000 5 |
|  | 9 5 |  |
| output | output | output |
| 2 | 17 | 10 |
| 2 | 23 | 10 |
| 2 | 17 | 10 |
|  | 11 |  |

Starter code:

Grader code:

Setup script:

Evaluation script: