#K74272. Package Delivery Status Determination

    ID: 34161 Type: Default 1000ms 256MiB

Package Delivery Status Determination

Package Delivery Status Determination

You are given a series of status updates for various packages. Each update consists of a package identifier, a status message, and a timestamp. Your task is to determine the final status for each package based on the update with the largest timestamp. In case two updates have the same timestamp for a package, the later one in the input order should be considered.

The final output should list all package IDs in lexicographical order along with their final statuses.

inputFormat

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

  • The first line contains an integer \(n\) denoting the number of updates.
  • Each of the next \(n\) lines contains an update in the form: package_id, status, timestamp. The fields are separated by a comma and a space. Note that the status may contain spaces.

outputFormat

For each package, output a line containing the package_id and its final status separated by a space. The packages must be listed in lexicographical order by package_id. The output is written to standard output (stdout).

## sample
6
PKG123, picked up, 100
PKG123, in transit, 200
PKG999, picked up, 150
PKG999, in transit, 250
PKG123, delivered, 300
PKG999, out for delivery, 275
PKG123 delivered

PKG999 out for delivery

</p>