#K66212. Current Book Holders

    ID: 32371 Type: Default 1000ms 256MiB

Current Book Holders

Current Book Holders

You are given a series of transactions related to a library’s book lending system. Each transaction is either a borrow or a return operation. When a book is borrowed, the transaction is in the format:

Borrow <memberID> <barcode>

and when a book is returned, the transaction is in the format:

Return <barcode>

Your task is to determine the current holder of each book. If a book has been returned, its status becomes (available). Otherwise, the book is held by the specified member. The output should list the final status of each book sorted in lexicographical order by barcode.

For example, given the transactions:

Borrow M1 B1
Borrow M2 B2
Return B1
Borrow M1 B3
Return B2

The final status of the books (sorted by barcode) is:

B1 available
B2 available
B3 M1

Note that if there are no transactions, nothing should be output.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (n) denoting the number of transactions. This is followed by (n) lines, each containing a transaction in one of the following formats:

Borrow <memberID> <barcode>
Return <barcode>

It is guaranteed that all (memberID) and (barcode) strings consist of alphanumeric characters without spaces.

outputFormat

Print the final status of each book to standard output (stdout). For every distinct barcode encountered in the transactions, output a line containing the barcode and its status (either a (memberID) or (available)), separated by a space. The books must be printed in lexicographical order of their barcodes.## sample

5
Borrow M1 B1
Borrow M2 B2
Return B1
Borrow M1 B3
Return B2
B1 available

B2 available B3 M1

</p>