A rolling event log keeps at most C entries in a bounded FIFO buffer. Apply Q operations in order:
PUSH x- append entry valuexto the back. If the buffer already holdsCentries, first evict the oldest (front) entry to make room, then append.POP- remove the oldest (front) entry if the buffer is non-empty; if it is empty, do nothing.
After all operations, output the remaining entries from oldest to newest.
Input format
Line 1: two integers C and Q.
Next Q lines: either PUSH x or POP.
Output format
If the buffer is empty at the end, print EMPTY. Otherwise print the remaining entries from oldest to newest, space-separated on one line.
Constraints
- 1 <= C <= 100000
- 1 <= Q <= 100000
- For
PUSH x: -1000000000 <= x <= 1000000000