#K76057. Restock Shelves

    ID: 34557 Type: Default 1000ms 256MiB

Restock Shelves

Restock Shelves

You are given an inventory of products and a sales report. Each product in the inventory is represented as a pair of a product code and its current stock count. The sales report contains the number of units sold for some of the products. Your task is to calculate the number of units to order for each product to reach the ideal stock level of 100.

For a product with a current stock count of current_stock and sold_units sold, the order quantity is computed using the formula:

\( units\_to\_order = 100 - (current\_stock - sold\_units) \)

If a product does not appear in the sales report, assume that sold_units = 0 for that product. Process the products in the order they appear in the inventory.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains an integer n, the number of products in the inventory.
  • The next n lines each contain a product code (a string without spaces) and an integer representing its current stock count, separated by a space.
  • The following line contains an integer m, the number of entries in the sales report.
  • The next m lines each contain a product code and an integer representing the number of units sold, separated by a space.

outputFormat

The output should be written to stdout. For each product in the inventory (in the same order as input), output a line containing the product code and the computed units to order (separated by a space).

## sample
3
apple 50
banana 30
orange 75
2
apple 10
banana 5
apple 60

banana 75 orange 25

</p>