Lunch Queue

아직 제출이 없습니다시간 제한2.5초메모리 제한512 MB

문제

It is lunch time! That's why nn employees are coming to the canteen to have lunch. It is known that ii-th employee works in the team c_ic\_i and has impudence a_ia\_i

Suppose there are currently ll people in the queue. Positions in the queue are numbered from 11 to ll from the beginning of the queue. When a person comes to the canteen, he tries to get as close to the beginning of the queue as possible by staying next to one of his teammates. Formally, if a newcomer gets into the queue at the position kk (1kl+11 \leq k \leq l + 1), he shifts the kk-th person and everybody behind him one position back and gets the position kk. In particular, k=1k = 1 corresponds to the beginning of the queue and k=l+1k = l + 1 corresponds to the end of the queue.   

An employee ii can stay at the position kk only if two conditions are held:

  • After getting to the position kk, at least one of the neighbors of newcomer is from the same team c_ic\_i;
  • A newcomer is not shifting too much people for his level of impudence, namely: kl+1a_ik \geq l + 1 - a\_i.

Among all kk satisfying the conditions above the minimum possible is chosen. If there are no suitable values of kk, a newcomer simply takes place after the last person in the queue.

For example, if there are five people in the queue working in teams 1, 3, 4, 1, 3 respectively (starting from the beginning of the queue) and the newcomer works in team 1 and has impudence 3, he stays at the position 4 of the queue. After that, the sequence of the employee teams becomes 1, 3, 4, 1, 1, 3. Note that impudence value of 3 also allowed him to get to the position 3, but there would be no teammates next to him in that case, so the first condition is violated.

Knowing the order in which employees arrive and their values of c_ic\_i and a_ia\_i, find out how the queue will look like in the end.

입력

The first line contains an integer nn (1n400,0001 \le n \le 400\\,000), the number of employees.

Each of the next nn lines contains two integers c_ic\_i, a_ia\_i (1c_in1 \le c\_i \le n, 0a_i400,0000 \le a\_i \le 400\\,000), the team and the impudence of the ii-th employee.

출력

Output nn distinct integers from 11 to nn which are the indices of people in the queue from beginning of the queue to the end after all employees get to the canteen. Employees are indexed from 11 to nn in order of their appearance in the input data.