Majority
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
The votes are in! Mathematicians world-wide have been polled, and each has chosen their favorite number between 1 and 1000. Your goal is to tally the votes and determine what the most popular number is.
If there is a tie for the greatest number of votes, choose the smallest number with that many votes.
Input
Starts with a single line containing the number of test cases, between 1 and 100 inclusive. For each test case, there will be a single line giving the number of votes V (1 ≤ V ≤ 1000). Following that line will be V lines, each with a single integer vote between 1 and 1000.
Output
For each test case print in a separate line the most popular number. In the case of a tie print the smallest number with that number of votes.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 51%