#K61377. Top Student Selection
Top Student Selection
Top Student Selection
You are given several test cases. Each test case contains details of students along with their marks in two subjects: Mathematics and Science. Your task is to determine the top student for each test case based on the following criteria:
- The student with the highest aggregate score is the top student. The aggregate score is calculated as $$\text{Mathematics}+\text{Science}$$.
- If there is a tie in aggregate scores, the student with the higher Mathematics score is selected.
- If there is still a tie, choose the student whose name comes first in lexicographical order.
inputFormat
The input is given from standard input and consists of multiple lines:
- The first line contains an integer $$T$$, the number of test cases.
- For each test case, the first line contains an integer $$N$$, the number of students.
- This is followed by $$N$$ lines, each containing a student's information in the format: Name Mathematics Science, separated by spaces.
outputFormat
For each test case, output the name of the top student on a new line to standard output.## sample
2
3
Alice 98 99
Bob 95 96
Charlie 99 95
4
David 87 92
Eve 91 88
Frank 90 91
Gina 92 89
Alice
Gina
</p>