#K69972. Library Management System

    ID: 33205 Type: Default 1000ms 256MiB

Library Management System

Library Management System

Implement a Library Management System that supports four types of operations:

  • 1 reader_id book_id: Borrow a book. If the book is available, it becomes borrowed and its borrow count increases by one.
  • 2 reader_id book_id: Return a book, marking it as available.
  • 3 book_id: Check the availability of a book. Output Available if the book is not currently borrowed, and Not Available otherwise.
  • 4: Determine the most borrowed book. In case of a tie, choose the book with the smallest id.

Initially, all $N$ books are available. You are given $N$ (the number of books), $M$ (the number of readers), and $Q$ (the number of operations), followed by $Q$ operations. The goal is to process these operations and output the results for operations of type 3 and 4.

inputFormat

The input is read from stdin. The first line contains three space-separated integers: NN, MM, and QQ.

Each of the next QQ lines contains an operation in one of the following formats:

  • 1 reader_id book_id — Borrow a book.
  • 2 reader_id book_id — Return a book.
  • 3 book_id — Check the availability of a book.
  • 4 — Output the most borrowed book's id.

outputFormat

For each operation of type 3 or 4, print the result on a new line to stdout.

For an operation of type 3, output either Available or Not Available. For an operation of type 4, output a single integer representing the most borrowed book's id.## sample

5 3 7
1 1 2
1 2 3
3 2
2 1 2
3 2
4
1 3 2
Not Available

Available 2

</p>