#K72522. Library Book Collection Management

    ID: 33772 Type: Default 1000ms 256MiB

Library Book Collection Management

Library Book Collection Management

You are given a series of operations to manage a library's book collection. Each book has a unique integer book_id, and is stored in a shelf at a specific position.

The system supports three types of operations:

  • ADD book_id shelf_number position_on_shelf: Add a new book with the given id and position. If the book already exists, update its position.
  • MOVE book_id new_shelf_number new_position_on_shelf: Change the position of an existing book.
  • REMOVE book_id: Remove the book with the specified id from the collection.

After processing all operations, output the final state of the library. The books should be displayed in ascending order by their book_id, each on a separate line formatted as:

book_id (shelf, position)book\_id\ \,(shelf,\ position)

For example, if the final state has a book with id 101 on shelf 2 at position 5, it should be printed as:

101 (2, 5)

inputFormat

The input is given via stdin and has the following format:

  1. The first line contains a single integer n, the number of operations.
  2. The following n lines each contain one operation in one of the following formats:
  • ADD book_id shelf_number position_on_shelf
  • MOVE book_id new_shelf_number new_position_on_shelf
  • REMOVE book_id

All numbers are integers.

outputFormat

Output the final state of the library to stdout. For each book in the collection (after processing all operations), print a line in the following format:

book_id (shelf, position)book\_id\ \,(shelf,\ position)

The books must be sorted in ascending order by book_id. If there are no books in the collection, output nothing.

## sample
5
ADD 101 2 3
ADD 102 1 1
MOVE 101 2 5
REMOVE 102
ADD 103 1 2
101 (2, 5)

103 (1, 2)

</p>