Library Management System: searching for books by author and year
Task «Library Management System: searching for books by author and year»
Input Format
First line: integer N (1 ≤ N ≤ 1000) — the number of books. Next N lines, each contains the book title (a string without spaces, up to 100 characters), the author (a string without spaces, up to 100 characters), and the year of publication (an integer from 1000 to 2025), separated by a space. Then a line: integer M (1 ≤ M ≤ 100) — the number of queries. Next M lines, each contains the author (a string without spaces) and the year (an integer), separated by a space.
Output Format
For each query, output on a separate line the titles of books that satisfy the condition, separated by a space, in ascending order of publication year. If there are no books, output an empty line.