Race Results

Interview

Time limit1sMemory limit128 MB

Summary
Sort N finish times given as hours, minutes, and seconds in ascending order and print each on its own line.
Level

Easy3 of 10

Topics
Sorting, Implementation
Solved
No attempts yet

Problem

The herd has finished its first marathon! You are given NN finish times, each written as Hours HH, Minutes MM, and Seconds SS (1≤N≤5,0001 \le N \le 5{,}000, 0≤H≤990 \le H \le 99, 0≤M≤590 \le M \le 59, 0≤S≤590 \le S \le 59).

Sort these times in ascending order — comparing by hours, then minutes, then seconds, with the smallest (fastest) time first — and print them.

Input

  • Line 1: a single integer NN.
  • Lines 2 through N+1N+1: line i+1i+1 contains the ii-th cow's time as three space-separated integers: hours, minutes, and seconds.

Output

  • NN lines: each line contains one cow's time as three space-separated integers (hours, minutes, seconds), printed in ascending sorted order.

Examples1

  1. Example 1

    Input
    3
    11 20 20
    11 15 12
    14 20 14
    
    Expected output
    11 15 12
    11 20 20
    14 20 14