#K74467. Deck Master Operations

    ID: 34204 Type: Default 1000ms 256MiB

Deck Master Operations

Deck Master Operations

You are given a deck which can store playing cards. The deck is initially empty. You need to implement a system that processes a series of operations on this deck. The operations are:

  • add v suit: Add the card with integer value v and string suit suit to the deck. If the card already exists, ignore the operation.
  • remove v suit: Remove the card with value v and suit suit from the deck if it exists.
  • query highest: Query and print the highest value card in the deck. If multiple cards have the same value, the card whose suit has a smaller initial letter (in ASCII) is considered higher. Formally, if a card has value v and suit s, its key is \( (v, -\mathtt{ord}(s[0])) \). If the deck is empty, print Empty.
  • query lowest: Query and print the lowest value card in the deck. In the case of ties, the card whose suit has a smaller initial letter (in ASCII) is considered lower. Formally, the key is \( (v, \mathtt{ord}(s[0])) \). If the deck is empty, print Empty.

The operations are given sequentially and you must process them in order. The result of each query operation should be printed on a separate line.

inputFormat

The first line contains an integer n, representing the number of operations.

The following n lines each contain one operation in one of the formats described above.

outputFormat

For each query operation, output the result on a separate line. If the deck is empty at the time of a query, output Empty.

## sample
8
add 10 Hearts
add 5 Spades
add 7 Diamonds
query highest
query lowest
remove 10 Hearts
query highest
query lowest
10 Hearts

5 Spades 7 Diamonds 5 Spades

</p>