#K10241. Most Frequent Lake

    ID: 23203 Type: Default 1000ms 256MiB

Most Frequent Lake

Most Frequent Lake

You are given trip data for several queries. In each query, you are given the names of lakes visited during a trip. Your task is to find the lake with the highest number of visits and output both the lake name and the number of trips.

If multiple lakes share the highest frequency, choose the lake with the lexicographically smallest name (considering standard string order). Use \(\text{lexicographical order}\) for comparisons.

inputFormat

The input consists of multiple queries. The first line contains an integer T indicating the number of queries. Each query is given in two lines:

  • The first line contains an integer N representing the number of lake visits.
  • The second line contains N space-separated strings, each representing the name of a lake visited.

outputFormat

For each query, print a single line containing the name of the most frequently visited lake and the corresponding number of visits, separated by a space.

## sample
1
3
Lake1 Lake3 Lake1
Lake1 2

</p>