#C12999. Update Inventory

    ID: 42487 Type: Default 1000ms 256MiB

Update Inventory

Update Inventory

This problem requires you to update an inventory list based on a series of actions. You are given an initial inventory, and then a sequence of operations that either add an item to the inventory or remove an item from it. When removing an item, only the first occurrence is removed, and if the item is not present, the operation is ignored.

Formally, let \(I\) be the inventory and suppose you are given \(m\) operations \( (action_i, item_i) \) for \(i = 1, 2, \ldots, m\). For each operation, if \(action_i = \texttt{add}\), append \(item_i\) to \(I\); if \(action_i = \texttt{remove}\), remove the first occurrence of \(item_i\) from \(I\) if it exists. Your task is to output the updated inventory after processing all operations sequentially.

inputFormat

The first line contains an integer \(n\) representing the number of items in the initial inventory.

The second line contains \(n\) strings separated by spaces, representing the inventory items.

The third line contains an integer \(m\) representing the number of actions to perform.

The next \(m\) lines each contain two strings: an action (either add or remove) and the item name.

outputFormat

Output the updated inventory in a single line. The items should be printed in order separated by a single space. If the inventory is empty, output an empty line.

## sample
2
apple banana
1
add orange
apple banana orange