#C4799. Sort the Photos

    ID: 48376 Type: Default 1000ms 256MiB

Sort the Photos

Sort the Photos

You are given a collection of photos, each with an ID, a description, and a timestamp. Your task is to sort these photos in ascending order based on their timestamp, and if two photos have the same timestamp, order them lexicographically by their ID. In mathematical terms, for any two photos (p_i) and (p_j) with timestamps (t_i) and (t_j) and IDs (d_i) and (d_j), photo (p_i) should come before photo (p_j) if (t_i < t_j) or if (t_i = t_j) and (d_i < d_j).

inputFormat

The input is read from standard input (stdin). The first line contains a single integer (n) representing the number of photos. Each of the following (n \times 3) lines describes a photo in three lines:

  1. The first line is a string representing the photo's ID (without spaces).
  2. The second line is an integer representing the photo's timestamp.
  3. The third line is a string representing the photo's description (it may contain spaces).

outputFormat

The output should be printed to standard output (stdout). For each photo in the sorted order, print a single line containing the photo's ID, timestamp, and description, separated by a single space.## sample

3
photo1
1630447330
A photo of a cat
photo2
1630447330
A photo of a dog
photo3
1630447200
A photo of a tree
photo3 1630447200 A photo of a tree

photo1 1630447330 A photo of a cat photo2 1630447330 A photo of a dog

</p>