#K77277. Maximum Height Difference by Timestamp

    ID: 34829 Type: Default 1000ms 256MiB

Maximum Height Difference by Timestamp

Maximum Height Difference by Timestamp

You are given a series of activity events. Each event is represented by a pair of integers, \(t\) and \(d\), where \(t\) is the timestamp and \(d\) is the height difference at that timestamp.

Your task is to calculate the maximum height difference for each unique timestamp and output the results in ascending order of the timestamp. In mathematical terms, for each unique timestamp \(t\), you need to compute:

[ max_{{i | t_i = t}} d_i ]

Make sure to process the input from standard input (stdin) and output the results to standard output (stdout).

inputFormat

The first line contains a single integer \(n\) representing the number of activity events.

The following \(n\) lines each contain two space-separated integers, \(t\) and \(d\), where \(t\) is the timestamp and \(d\) is the height difference.

outputFormat

For each unique timestamp, output a line containing the timestamp and the maximum height difference at that timestamp, separated by a single space. The output should be in ascending order of timestamp.

## sample
5
1 3
3 -1
1 -2
2 4
3 5
1 3

2 4 3 5

</p>