cho.sh
Notes
Loading...

Candy Box

Time limit

2s

Memory limit

128 MB

Problem

Sujeong keeps candies of many flavors in a candy box to reward her younger sibling.

Each candy flavor is represented by an integer from 1 to 1,000,000. A smaller number means a tastier candy: 1 is the tastiest flavor, and 1,000,000 is the least tasty flavor.

When her sibling behaves well, Sujeong takes one candy from the box according to a requested rank by tastiness. For example, she may take the 1st tastiest candy for very good behavior, or the 6th tastiest candy for slightly good behavior.

Because the box can contain very many candies, finding the right candy by hand every time is difficult. Process the given operations and output the flavor number of each candy taken from the box.

Input

The first line contains the number n of times Sujeong touches the candy box. (1 <= n <= 100,000)

Each of the next n lines contains one operation.

  • If A = 1, one candy is taken from the box. The line contains two integers A B, where B is the tastiness rank of the candy to take. That candy is removed from the box.
  • If A = 2, the number of candies of one flavor changes. The line contains three integers A B C, where B is the flavor number and C is the change in count. If C is positive, candies of that flavor are added; if C is negative, candies of that flavor are removed.

The candy box is initially empty. At every moment, the total number of candies in the box does not exceed 2,000,000,000. Invalid input, such as taking or removing candies that do not exist, is not given.

Output

For every operation with A = 1, print the flavor number of the candy that is taken, one per line.