#K8956. Database Activity Update Tracker

    ID: 37557 Type: Default 1000ms 256MiB

Database Activity Update Tracker

Database Activity Update Tracker

This problem is about tracking user activity updates in a database. You are given n updates, each containing a user ID and a timestamp. Your task is to determine the most recent activity timestamp for each user.

The timestamp is given in the format \(YYYY\text{-}MM\text{-}DD\ HH:MM:SS\). You may assume that lexicographical order applies; that is, a larger timestamp string corresponds to a later time.

You should then output the resulting records in ascending order of user IDs. Each record contains the user ID and the respective latest timestamp.

inputFormat

The first line contains an integer n, the number of updates. The next n lines each contain an update in the following format:

userID timestamp

Note: The timestamp will be in the format \(YYYY\text{-}MM\text{-}DD\ HH:MM:SS\) and may contain a space between the date and time.

outputFormat

Output the current state of the database as multiple lines. Each line should contain a user ID followed by a space and the most recent timestamp of that user. The output should be sorted in ascending order by user ID.

## sample
5
123 2023-02-15 08:45:00
456 2023-02-15 09:00:00
123 2023-02-15 09:30:00
789 2023-02-15 10:00:00
456 2023-02-15 09:15:00
123 2023-02-15 09:30:00

456 2023-02-15 09:15:00 789 2023-02-15 10:00:00

</p>