#K60917. Find the Earliest Chat Room

    ID: 31193 Type: Default 1000ms 256MiB

Find the Earliest Chat Room

Find the Earliest Chat Room

Given a list of chat rooms, each represented by a pair of integers where the first integer ci is the chat room id and the second integer ti is its last active timestamp, your task is to find the chat room with the earliest (i.e. minimum) last active timestamp. In case of a tie (i.e. multiple chat rooms having the same minimum timestamp), output the chat room with the smallest id.

The problem can be formulated as follows:

\(\min_{1 \leq i \leq N} \left\{t_i\right\}\)

If there exists a tie, choose the one with \(\min\{c_i\}\) among those.

inputFormat

The first line of input contains a single integer \(N\) representing the number of chat rooms.

The following \(N\) lines each contain two space-separated integers \(c_i\) and \(t_i\), where \(c_i\) is the id of the chat room and \(t_i\) is its last active timestamp.

outputFormat

Output the id of the chat room that has the earliest (i.e. smallest) last active timestamp. In case of ties, output the smallest chat room id among them.

## sample
1
101 1610000000
101

</p>