#K43952. Taco Command Processor

    ID: 27423 Type: Default 1000ms 256MiB

Taco Command Processor

Taco Command Processor

You are given an integer n followed by n commands. Each command is either an operation to add a character or remove the last character from a text.

The commands are of two types:

  • ADD x — Append the character x to the end of the text.
  • REMOVE — Remove the last character from the text. It is guaranteed that when a REMOVE command is issued, the text is non-empty.

Your task is to process all the commands in sequence and output the resulting text.

Formally, let \(S\) be initially an empty string. For each command:

  • If the command is \(\texttt{ADD } x\), update \(S = S \Vert x\).
  • If the command is \(\texttt{REMOVE}\), remove the last character from \(S\).

Output the final string after all commands have been processed.

inputFormat

The input is given via stdin and has the following format:

 n
 command_1
 command_2
 ...
 command_n

Here, n is an integer representing the number of commands, and each command_i is a string that is either in the format ADD x or REMOVE.

outputFormat

Output the final text as a string to stdout after processing all the commands.

## sample
7
ADD a
ADD b
ADD c
REMOVE
ADD d
REMOVE
REMOVE
a