#C1995. Inventory Manager System

    ID: 45261 Type: Default 1000ms 256MiB

Inventory Manager System

Inventory Manager System

You are tasked with designing an inventory management system to track product quantities across multiple warehouses over a series of days. The system supports three operations:

  • Update Operation: Set the quantity of a given product in a specific warehouse on a given day.
  • Total Query: Retrieve the sum of the quantities of a given product across all warehouses on a specified day.
  • Maximum Query: Retrieve the maximum quantity of a given product found in any one warehouse on a specified day.

Initially, no product is present in any warehouse (or you may consider the quantity to be 0). Each update operation resets the quantity for that product in the given warehouse and day. Note that queries only consider the data for the particular day specified (i.e. updates from other days are not aggregated).

The operations are provided via standard input (stdin) and responses must be printed via standard output (stdout). The input format is described below.

When implementing your solution, make sure your code correctly parses and executes the operations in the order given.

inputFormat

The first line contains two integers n and d, which are the number of warehouses and the number of days respectively.

The second line contains an integer q, representing the number of operations.

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

  • Update Operation: 1 day warehouse_id product_id qty
  • Total Query: 2 day product_id
  • Maximum Query: 3 day product_id

It is guaranteed that the operations are valid. For update operations, the system sets the quantity for that warehouse and day. For query operations, print the answer on a new line in the order they appear.

outputFormat

For each query operation (types 2 and 3), output a single integer on a new line representing either the total or the maximum quantity for the product on that day.

## sample
3 5
10
1 1 1 100 50
1 2 2 100 70
1 2 3 100 40
2 2 100
3 2 100
1 3 2 100 60
2 2 100
2 3 100
3 2 100
3 3 100
110

70 110 60 70 60

</p>