#K37257. List Operations Simulation
List Operations Simulation
List Operations Simulation
You are given an integer \(k\) representing the number of commands followed by \(k\) lines, each containing a command.
Each command is one of the following two types:
APPEND x
: Append the positive integer \(x\) to the end of the list.REMOVE
: Remove an element from the front of the list if the list is not empty.
After processing all commands in order, output the final state of the list.
Note: If the list becomes empty, output an empty line.
inputFormat
The first line contains a single integer \(k\), the number of commands.
The following \(k\) lines each contain a command, formatted as either APPEND x
where \(x\) is a positive integer, or REMOVE
.
outputFormat
Output the final list of integers after processing all commands. Print the integers separated by a single space. If the list is empty, output an empty line.
## sample4
APPEND 3
APPEND 5
REMOVE
APPEND 2
5 2