#K65187. Server Latest Update Tracker

    ID: 32142 Type: Default 1000ms 256MiB

Server Latest Update Tracker

Server Latest Update Tracker

You are given logs of server updates. Each update is identified by a server ID and a timestamp. For each test case, you need to determine the most recent (latest) update for each server. For a given server with updates \(t_1, t_2, \dots, t_n\), you need to compute its latest update as \(\max\{t_1, t_2, \dots, t_n\}\). Finally, you must output the server update pairs in ascending order of the server IDs.

The input begins with the number of test cases, followed by the details for each test case.

inputFormat

The first line of input contains an integer \(T\) representing the number of test cases. For each test case:

  • The first line contains an integer \(U\) representing the number of updates.
  • The next \(U\) lines each contain two space-separated integers: a server ID and a timestamp.

All input is provided via standard input (stdin).

outputFormat

For each test case, output the most recent update for each server in ascending order of server IDs. Each line should contain a server ID and its latest timestamp separated by a space. Separate the outputs for different test cases with an empty line. All output should be written to standard output (stdout).

## sample
2
5
1 100
2 200
1 150
2 250
3 300
3
1 400
1 250
2 100
1 150

2 250 3 300

1 400 2 100

</p>