#C1262. Book Shelf Search
Book Shelf Search
Book Shelf Search
You are given several bookshelves, where each shelf contains a sorted list of unique book codes. For a given series of queries, determine on which shelf a specific book code is located. If the code is not present on any shelf, output "Not Found".
Formally, let there be shelves and each shelf contains a sorted list of book codes. For each query code , find an index (with ) such that . If no such shelf exists, output (\text{Not Found}).
inputFormat
The input is given via standard input in the following format:
- The first line contains an integer , the number of shelves.
- The next lines each describe a shelf. Each of these lines starts with an integer , the number of books on the shelf, followed by integers representing the sorted book codes on that shelf.
- The next line contains an integer , the number of queries.
- The last line contains integers, each representing a query book code.
Note: If , then there are no shelf lines.
outputFormat
For each query, print the 1-indexed shelf number in which the book code is found. If the book code isn’t present in any shelf, print "Not Found". Each answer should be printed on a new line.## sample
3
5 10 20 30 40 50
5 60 70 80 90 100
5 110 120 130 140 150
2
40 85
1
Not Found
</p>