#K12841. Most Frequent Element

    ID: 23780 Type: Default 1000ms 256MiB

Most Frequent Element

Most Frequent Element

You are given several test cases. In each test case, you are provided with a list of integers. Your task is to determine the smallest integer that appears most frequently in the list. If multiple integers appear with the same maximum frequency, return the smallest among them.

For example, in the list [1, 2, 2, 1, 3], both 1 and 2 appear twice. Since 1 is smaller than 2, the answer is 1.

Read the input from standard input and write the output to standard output.

inputFormat

The input starts with an integer t representing the number of test cases. Each test case consists of two lines: the first line contains an integer n, the number of elements in the list, and the second line contains n space-separated integers.

outputFormat

For each test case, output a single line containing the smallest integer that appears with the highest frequency in the corresponding list.

## sample
1
5
1 2 2 1 3
1

</p>