Submit Best Submissions All Submissions

478. Egypt in the World Cup


Problem Statement:
That was an unforgettable day! Finally Egypt has reached the FIFA World Cup for the first time since its last appearance in 1990! In the world cup the teams are divided in separate groups, and each team plays with the other teams in the same group and the top teams with the most number of points go to the next round.

You are given the name of each team, and how many points that team got, and your task is to find the name of the team with the highest number of points.

For simplicity, the points in this problems don't follow any rules, also the number of teams in a group can be an arbitrary number (not always 4), and you can find a team in a group of 4 teams with 100 points, that's okay in this problem.


Input Format:
Your program will be tested on one or more test cases. The first line of the input will be a single integer T (1 ≤ T ≤ 100) representing the number of test cases. Followed by T test cases.

Each test case starts with a line containing an integer N (the number of teams in the group, 2 ≤ N ≤ 100).

Followed by N lines, each line represents a team. Each line starts with a string of at least 1 and at most 10 lower case English letters, then a space then the number of points that team got (the number of points is non-negative and will be at most 1000).

The names of the teams within the same test case are guaranteed to be unique, and there will be at least 1 team with positive score.


Output Format:
For each test case, print a single line containing the name of the team with the highest number of points. It's guaranteed that exactly 1 team will have that highest number.


Sample Input:
2 3 brazil 7 egypt 10 spain 5 2 teama 4 teamb 30


Sample Output:
egypt teamb





Added by: ahmed_aly
Added at: 2017-10-09 20:00:00 UTC
Time Limit: 2 seconds
Partial score: No
Source:A2OJ Code Battle Round 1