#C9515. Person with the Most Pages

    ID: 53617 Type: Default 1000ms 256MiB

Person with the Most Pages

Person with the Most Pages

You are given data about several people and the pages read from multiple books by each person. For each person, you will be provided with a list of numbers, where the first number of the list indicates the number of books read, followed by the pages read for each book.

Your task is to determine the index (0-indexed) of the person who read the maximum total number of pages. In case there is a tie (i.e. more than one person has the same total number of pages), return the smallest index among them.

The total number of pages for a person can be computed as follows:

\( total\_pages = \sum_{j=1}^{m} pages_j \),

where \( m \) is the number of books the person read.

inputFormat

The first line of input contains an integer \(n\) representing the number of people.

Each of the next \(n\) lines describes the books read by a person. Each line starts with an integer \(m\) denoting the number of books read by that person, followed by \(m\) space-separated integers, each representing the number of pages of a book.

All input is provided via standard input (stdin).

outputFormat

Output a single integer that represents the 0-indexed index of the person who read the maximum total number of pages. In case of a tie, output the smallest index. The result should be printed to standard output (stdout).

## sample
3
3 10 20 30
3 15 25 35
2 30 30
1