#K68042. Shelf with Maximum Genre Books

    ID: 32776 Type: Default 1000ms 256MiB

Shelf with Maximum Genre Books

Shelf with Maximum Genre Books

Given a collection of bookshelves, each represented as a list of non-negative integers where each integer corresponds to the number of books of a particular genre, your task is to determine the index of the bookshelf that contains the maximum number of books for a specified genre.

The input begins with two integers: n (the number of bookshelves) and g (the genre index to inspect). This is followed by n lines, each containing a list of non-negative integers that represent the counts of books for various genres on that shelf.

If all shelves have zero books for the chosen genre, output No books available!. Otherwise, output the index of the shelf with the highest count of books for that genre. In case of a tie, choose the shelf with the smallest index.

The problem can be formulated using the following mathematical notation:

Let \(A_{i,j}\) denote the number of books on the \(i\)-th shelf for the \(j\)-th genre. For a given genre index \(g\), find the smallest index \(i\) such that \(A_{i,g}\) is maximized, provided that \(\max_{i} A_{i,g} > 0\); otherwise, output No books available!.

inputFormat

The first line contains two space-separated integers: n (the number of bookshelves) and g (the genre index to inspect).

This is followed by n lines. Each line consists of space-separated non-negative integers representing the count of books of each genre on that shelf.

outputFormat

Output a single line containing the index of the shelf with the highest count of books for the specified genre. If no shelf has a positive count for that genre, output No books available!.

## sample
3 1
3 5 2
4 2 7
5 5 1
0

</p>