#C9053. Library Management Operations

    ID: 53104 Type: Default 1000ms 256MiB

Library Management Operations

Library Management Operations

You are given a library organizing system with ( R ) rooms, each having ( S ) shelves, and every shelf holds ( B ) books. The library entries are given in a specific order: for each room, the room identifier is provided, and then for each shelf in that room, the shelf identifier is given, followed by the titles of the ( B ) books on that shelf. After the library data, a number of operations follow. There are three types of operations:

  1. Update a book title: This operation is indicated by 1 room shelf index new_title, which updates the title of the book at the given room, shelf, and index.

  2. Retrieve a book title: Indicated by 2 room shelf index, this returns the title of the book at the specified location.

  3. Count books: Indicated by either 3 room (which counts all books in the room) or 3 room shelf (which counts the books on a particular shelf of that room).

All indices for rooms, shelves, and books are 1-indexed. Input is provided via standard input and output must be written to standard output.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains three integers ( R ), ( S ), and ( B ) separated by spaces.
  • The next ( R + R \times S \times (1+B) ) lines describe the library data. For each room (total ( R ) rooms):
    • A line with the room identifier (an integer).
    • For each shelf (total ( S ) shelves):
      • A line with the shelf identifier (an integer).
      • ( B ) lines each containing a string representing a book title on that shelf.
  • The following line contains an integer ( Q ) denoting the number of operations.
  • The next ( Q ) lines each describe an operation in one of the following forms:
    • 1 room shelf index new_title
    • 2 room shelf index
    • 3 room or 3 room shelf

outputFormat

For each operation that produces an output (i.e. type 2 and type 3 operations), print the result on a separate line to stdout. For operation type 2, print the book's title. For operation type 3, print the count of books.## sample

2 2 2
1
1
Gone_with_the_Wind
The_Great_Gatsby
2
To_Kill_a_Mockingbird
1984
2
1
Pride_and_Prejudice
Moby_Dick
2
War_and_Peace
Ulysses
4
2 1 2 1
1 2 1 2 Crime_and_Punishment
2 2 1 2
3 1
To_Kill_a_Mockingbird

Crime_and_Punishment 4

</p>