## Maintaining an Envelope

View as PDF

Points: 30
Time limit: 3.0s
Memory limit: 1G

Problem types

There is a 2D-plane where only lattice points with their x-coordinates from to are of interest.

Support the following operations:

• 1 n m b Add a line with an ID of in the form of to the plane. All line IDs are guaranteed to be distinct.
• 2 n Delete the line with an ID of . It is guaranteed that the line exists at this time.
• 3 c Output the ID of the line that gives the minimum value at . If multiple lines give the minimum value, output the ID of the line with a lower ID. It is guaranteed that there is least one line on the plane at this time.

You will be asked to support these operations a total of times.

#### Input Specification

The first line of input will contain two numbers: and .

The next lines each contain an operation, as described above.

#### Output Specification

For each of the 3 c operation, output one line: the answer, as described above.

#### Sample Input

100 8
1 3 -10 2
1 1 -9 6
1 2 -4 4
1 4 1 1
3 39
2 4
2 3
3 40

#### Sample Output

3
1