#K39597. Bookstore Inventory Management

    ID: 26455 Type: Default 1000ms 256MiB

Bookstore Inventory Management

Bookstore Inventory Management

You are given the task to manage the inventory for a bookstore. Initially, the bookstore has n books with specific stock quantities, and you need to handle m operations. Each operation is either an update or a query:

  • update ISBN quantity: Increase the stock for the book with the given ISBN by the specified quantity. If the ISBN does not exist, add it to the inventory with the provided quantity.
  • query ISBN: Output the current stock quantity of the book with the given ISBN. If the book is not found, output 0.

The operations must be processed in the order they are given. The solution should read from standard input and write to standard output.

Note: There is no removal operation; the update command only increments the current stock.

For those who like formulas: the update operation can be expressed as \( S_{new} = S_{old} + \Delta S \), where \( \Delta S \) is the update quantity.

inputFormat

The first line of input contains two integers n and m separated by a space, where n is the number of books in the initial inventory and m is the number of operations.

The next n lines each contain a string and an integer, representing a book's ISBN and its stock quantity.

The following m lines each contain an operation in one of the following formats:

  • update ISBN quantity
  • query ISBN

outputFormat

For each query operation, output the current quantity of the book with the given ISBN on a separate line. If the book does not exist, output 0.

## sample
4 3
9780307938 10
9780374533 5
9780143124 2
9780316769 8
update 9780307938 5
query 9780307938
query 9780143124
15

2

</p>