#C2840. Manage Movie Collection

    ID: 46201 Type: Default 1000ms 256MiB

Manage Movie Collection

Manage Movie Collection

You are given a shelf with n slots to hold movies. Each slot can store a movie with a given rating. Initially, each slot is empty (rating is 0). You will be given m operations to perform on the shelf. There are two types of operations:

  • Type 1: 1 p r — Place a movie with rating r into slot p. (Note: p is 1-indexed.)
  • Type 2: 2 p — Remove the movie from slot p (set its rating to 0).

After each operation, output the maximum movie rating currently present on the shelf. If no movie is present, the maximum rating is 0.

The task is to process all operations and output the maximum rating after each one.

Note: For removal, if the movie being removed has the maximum rating, recalculate the maximum over all slots.

inputFormat

The input is given via standard input and has the following format:

 n m
 op1
 op2
 ...
 op_m

Here, the first line contains two integers n (number of slots) and m (number of operations). Each of the next m lines represents an operation. For a type 1 operation, the line contains three integers: 1, p, r. For a type 2 operation, the line contains two integers: 2, p.

outputFormat

After processing each operation, output the current maximum movie rating on a new line. Thus, there will be m lines in the output.

## sample
5 6
1 3 10
1 1 5
1 5 7
2 3
1 2 20
2 5
10

10 10 7 20 20

</p>