#C722. Most Frequent Number on Tablets

    ID: 51067 Type: Default 1000ms 256MiB

Most Frequent Number on Tablets

Most Frequent Number on Tablets

You are given T tablets. Each tablet consists of an integer N followed by N integers. For each tablet, your task is to find the number that appears most frequently. If there is more than one candidate for the most frequent number, choose the smallest one.

Input Format: The first line of input contains an integer T denoting the number of tablets. Each of the following T lines starts with an integer N (the number of numbers on the tablet), followed by N space-separated integers.

Output Format: Output a single line containing T integers; the i-th integer should be the result of the i-th tablet. The answers should be printed in order and separated by a single space.

The constraints allow you to use straightforward counting techniques. Specifically, if you denote the number of tablets by $T$ and for each tablet the number of integers by $N$, then you are to compute the frequency of each number and output the smallest number among those that appear the maximum number of times.

inputFormat

The input is provided via standard input (stdin) and follows this format:

T
N1 a1 a2 ... aN1
N2 b1 b2 ... bN2
...
NT c1 c2 ... cNT

Where $T$ denotes the number of tablets, and for each tablet, the first integer is the number of elements on that tablet, followed by the respective integers.

outputFormat

Print a single line to standard output (stdout) containing the most frequent number for each tablet, separated by a single space. In case of a tie, print the smallest number among those tied for the highest frequency.

## sample
1
1 1
1

</p>