#C10191. Stock Update
Stock Update
Stock Update
You are given a list of stock items with their quantities and a list of transactions. Each transaction specifies an item and the number of units sold. Update the stock by subtracting the sold quantities from the initial stock.
More formally, suppose the stock is represented by a dictionary \(S\) and the transactions by a list of pairs \((item, quantity)\). Then for every transaction \((i, q)\), if \(i\) is a key in \(S\), update \(S[i] = S[i] - q\). Transactions referring to items not in the stock are ignored.
The input begins with an integer \(n\) (the number of stock items) followed by \(n\) lines of item names and their quantities. After that, an integer \(m\) is given, followed by \(m\) lines of transactions.
inputFormat
The input is given via standard input (stdin) with the following format:
- An integer \(n\) representing the number of stock items.
- \(n\) lines, each containing a string (item name) and an integer (stock quantity), separated by a space.
- An integer \(m\) representing the number of transactions.
- \(m\) lines, each containing a string (item name) and an integer (quantity sold), separated by a space.
outputFormat
Output the updated stock for each item (in the same order as the input) to standard output (stdout). Each line should contain the item name and its updated quantity, separated by a space.
## sample3
apple 10
banana 5
orange 8
3
apple 5
banana 2
orange 1
apple 5
banana 3
orange 7
</p>