Maximum Frequency Stack#10379

Maximum Frequency Stack

1 second
128 megabytes
Medium

Design a data structure similar to a stack that allows adding elements and removing the most frequent element from the stack.

The following commands are supported:

Input

Consists of commands, one per line.

Output

For each pop operation, print the result on a separate line.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading