#C9428. Most Frequent Event

    ID: 53520 Type: Default 1000ms 256MiB

Most Frequent Event

Most Frequent Event

You are given a sequence of log entries where each entry consists of a timestamp and an event type. Your task is to determine the event type that appears most frequently. In case of a tie, you should return the event type that appeared first among those tied based on its timestamp.

Mathematically, for each event type e, let f(e) be the number of times it appears. You need to output an event e* such that:

$$e* = \min_{\{e \mid f(e) = \max f(e)\}} \{ first(e) \} $$

where first(e) is the timestamp of the first occurrence of event e.

inputFormat

The input is read from stdin and has the following format:

n
timestamp_1 event_type_1
timestamp_2 event_type_2
... 
timestamp_n event_type_n

Here, n is the number of log entries. Each of the next n lines contains an integer timestamp and a string denoting the event type, separated by whitespace.

outputFormat

Output a single line to stdout containing the event type that occurs the most frequently. In case multiple event types have the same highest frequency, output the one with the smallest timestamp of first occurrence.

## sample
1
1 login
login