#K59512. List Operation Processor

    ID: 30881 Type: Default 1000ms 256MiB

List Operation Processor

List Operation Processor

You are given a list that supports three types of operations:

  1. ADD x: Append the integer \(x\) to the end of the list.
  2. REMOVE x: Remove the first occurrence of the integer \(x\) from the list if it exists.
  3. MAX: Print the maximum element in the list. If the list is empty, print EMPTY.

You will be given \(n\) operations. Your task is to process these operations sequentially and output the result of each MAX operation.

Example:

Input:
8
ADD 3
ADD 1
MAX
REMOVE 3
MAX
ADD 2
REMOVE 4
MAX

Output: 3 1 2

</p>

inputFormat

The first line contains an integer \(n\) representing the number of operations. Each of the following \(n\) lines contains a string representing one of the three operations:

  • ADD x where \(x\) is an integer.
  • REMOVE x where \(x\) is an integer.
  • MAX

outputFormat

For each MAX operation, output the maximum element of the list on a new line. If the list is empty during a MAX operation, output EMPTY instead.

## sample
8
ADD 3
ADD 1
MAX
REMOVE 3
MAX
ADD 2
REMOVE 4
MAX
3

1 2

</p>