| Author: | Pavel Mesenev | Time limit: | 2 sec | |
| Input file: | Standard input | Memory limit: | 256 Mb | |
| Output file: | Standard output |
Implement a FIFO queue supporting n operations of two kinds:
It is guaranteed that POP is never called on an empty queue. You must use only a Stack ADT (push / pop / top from one end) as your underlying storage — no deque, no list indexing from the front, no built-in queue.
The first line contains one integer n — the number of operations. Each of the next n lines is either PUSH x or POP.
For each POP, print the removed value on its own line, in order.
1 ≤ n ≤ 2 ⋅ 105
1 ≤ x ≤ 109
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|