#K57637. Top Three Runners

    ID: 30465 Type: Default 1000ms 256MiB

Top Three Runners

Top Three Runners

You are given the number of runners and their race completion times in the format \(hh:mm:ss\). Your task is to determine the top three fastest runners. In case there are fewer than three runners, return them sorted by their race times.

The input consists of a number \(N\) representing the total runners followed by \(N\) lines, each containing a runner's ID and their completion time separated by a space. The output should list the IDs of the top three fastest runners (or all runners if \(N < 3\)) sorted by their times (from fastest to slowest).

Note: In the event of ties (i.e. equal completion times), maintain the order in which the runners appear in the input.

inputFormat

The first line contains an integer \(N\) representing the number of runners.

The following \(N\) lines each contain a runner's ID (an integer) and a completion time in the format hh:mm:ss, separated by a space.

outputFormat

Output a single line containing the IDs of the top three fastest runners (or all runners if \(N < 3\)) separated by a space.

## sample
4
202 02:15:30
101 01:45:22
303 02:10:15
404 01:44:20
404 101 303