#K51522. Competition Winner Determination

    ID: 29106 Type: Default 1000ms 256MiB

Competition Winner Determination

Competition Winner Determination

This problem simulates a multi‐round competitive game where several participants accumulate scores over multiple rounds. In each round, the scores are provided in the format Name:Score for each participant. The overall cumulative score for a participant is given by the formula:

Si=j=1nsijS_i = \sum_{j=1}^{n} s_{ij}

where \(s_{ij}\) is the score obtained by participant \(i\) in round \(j\) and \(n\) is the number of rounds. The winner is determined as the participant with the highest cumulative score. In case of ties, the winner is the one who reached the maximum score first (i.e. whose first appearance contributing to that cumulative score comes earliest during the rounds).

You are given multiple test cases. Each test case starts with a number indicating the number of rounds, followed by the rounds details. Your task is to determine the overall winner 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 \(N\) indicating the number of rounds. This is followed by \(N\) lines where each line contains one or more participant scores separated by spaces, in the format Name:Score.

For example:

2
3
Alice:25 Bob:20 Charlie:30
Alice:30 Charlie:20
Bob:50 Charlie:10
2
Dana:45 Eva:20
Dana:20 Eva:45

outputFormat

For each test case, output the overall winner on a separate line. The winner is the participant with the highest cumulative score, and if there is a tie, the participant who reached that score first is the winner.

## sample
1
1
Alice:100
Alice