#C2589. The Most Frequent Species

    ID: 45921 Type: Default 1000ms 256MiB

The Most Frequent Species

The Most Frequent Species

You are given T test cases. For each test case, a photographer has taken N photos of wildlife. Each photo contains a label representing a species. Your task is to determine the species that appears most frequently in the collection. In the case of a tie (i.e. multiple species occur with the same maximum frequency), output the smallest species label among them. If no photo was taken (i.e. N = 0), output (\text{None}).

Input Format:

  • The first line contains an integer \(T\), the number of test cases.
  • For each test case, the first integer is \(N\), the number of photos, followed by \(N\) integers representing the species labels.

Output Format: For each test case, output a single line containing the species label that appears most frequently. If no photos were taken, output None.

inputFormat

The input is read from standard input. The first line contains an integer (T), denoting the number of test cases. Then for each test case, there is a line starting with an integer (N) (the number of photos), followed by (N) space-separated integers representing the species labels.

outputFormat

For each test case, print the species label that appears most frequently on a new line. In case of a tie, output the smallest label. If (N = 0), print None.## sample

2
5 3 3 2 5 2
4 1 2 2 1
2

1

</p>