#C10058. Find Book Location in a Library

    ID: 39221 Type: Default 1000ms 256MiB

Find Book Location in a Library

Find Book Location in a Library

You are given a library organized as a three-dimensional structure. The library consists of multiple floors; each floor has several bookshelves, and each bookshelf contains a list of book IDs. Your task is to locate a specific book by its ID.

The library is searched floor by floor, and within each floor the shelves are scanned sequentially. If the book is found, output the corresponding floor and shelf indices. Otherwise, output ( -1\ -1) (formatted in LaTeX as ( -1, -1 )).

inputFormat

Input is read from standard input (stdin). The first line contains an integer ( F ) representing the number of floors. For each floor, the first number is an integer ( S ) representing the number of shelves on that floor. Then, for each shelf, the first integer ( N ) indicates the number of books on that shelf followed by ( N ) space-separated integers representing the book IDs. The last line of the input contains the target book ID to search for.

outputFormat

Output two space-separated integers to standard output (stdout): the floor index and shelf index where the book is located. If the book is not found, output ( -1\ -1 ) instead.## sample

3
2
3 1 2 3
3 4 5 6
2
2 7 8
4 9 10 11 12
2
3 13 14 15
2 16 17
10
1 1

</p>