#C10510. Top Rated Books

    ID: 39724 Type: Default 1000ms 256MiB

Top Rated Books

Top Rated Books

You are managing an online bookstore system where users rate the books they have read. Your task is to determine, for each user, the top-rated book. For each user, let (r_{ij}) denote the rating of the (j)-th book. Then, the top-rated book is the one with the maximum rating (\max_j {r_{ij}}). In case of a tie, choose the book that appears first in the input order.

inputFormat

The input begins with an integer (N) representing the number of users. For each user, the first line contains an integer (B) indicating the number of books. The following (B) lines each contain a book title and an integer rating separated by a space. The input is provided via standard input (stdin).

outputFormat

Output the title of the top-rated book for each user on a new line. The output should be printed to the standard output (stdout).## sample

1
1
Single_Book 5
Single_Book

</p>