12691269 SUSTech Online Judge
Problem 1269 --Magic Queue

1269: Magic Queue

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 687  Solved: 241
[Submit][Status][Web Board]

Description

IceRuler likes Queues. So he gives you an empty queue initially and some operations on this queue.

The operations contains:

1. E x           Enqueue x .
2. D              Dequeue
3. A              Print the head of the queue.

Finally, You should output all elements in the queue after all operations.

Input

There is only one testcase. The first line is integer n, the number of operations. (1 <= n <= 20000000) Then n lines for these operations, x in int range.

Output

Do each operation, if it is type 'A', print current queue head in one line. After doing all operations, output the final queue elements in one line, if the queue is empty, print nothing. It is guaranteed that all operations are legal.

Sample Input

7
E 1
E 2
E 3
A
D
E 1
A

Sample Output

1
2   
2 3 1

HINT

Source

 

[Submit][Status]