#K36457. Most Borrowed Book

    ID: 25758 Type: Default 1000ms 256MiB

Most Borrowed Book

Most Borrowed Book

In a library system, multiple book borrow records are maintained. For each test case, you are given a series of book titles corresponding to borrow events. Your task is to determine the book that has been borrowed the most times.

If two or more books share the maximum borrow count, output the title that is lexicographically smallest. This problem tests your ability to process input efficiently, use appropriate data structures, and handle tie-breaking based on string ordering.

Note: Pay careful attention to edge cases such as test cases with only one record.

inputFormat

The input begins with an integer T, the number of test cases. For each test case: • The first line contains an integer N, representing the number of book records. • The following N lines each contain a book title (which may include spaces).

Input is read from standard input (stdin).

outputFormat

For each test case, output a single line containing the title of the most borrowed book. In the event of a tie, output the lexicographically smallest title. The output should be written to standard output (stdout).## sample

1
1
Book Title
Book Title

</p>