#C4426. Best Scores

    ID: 47963 Type: Default 1000ms 256MiB

Best Scores

Best Scores

You are given a series of test cases. In each test case, a number of submissions are made by various participants. Each submission consists of a participant's ID and the score they obtained in that submission. A participant can submit multiple times; your task is to compute the highest score achieved by each participant.

For each test case, you should output the number of unique participants, followed by each participant's ID and their highest score. The results for each test case must list the participants in ascending order of their IDs.

Note: All formulas, if any, are given in \( \LaTeX \) format. Ensure that you read the input from stdin and output the result to stdout.

inputFormat

The input begins with an integer \(T\) denoting the number of test cases. For each test case, the input format is as follows:

  • An integer \(N\) representing the number of submissions.
  • Followed by \(N\) lines, each containing two integers \(P\) and \(S\), where \(P\) is the participant's unique identifier and \(S\) is the score of the submission.

Input is read from stdin.

outputFormat

For each test case, output the results in the following format:

  • First, print an integer \(M\) — the number of unique participants in that test case.
  • Then print \(M\) lines, each line containing two integers: the participant's ID and their highest score, sorted in ascending order by participant ID.

The output for all test cases is printed to stdout.

## sample
2
5
1 85
2 90
1 95
3 80
2 92
4
4 75
4 85
4 80
4 90
3

1 95 2 92 3 80 1 4 90

</p>