| Advanced Data Structures |
|---|
| Finished |
Your task is to implement a retroactive queue.
A data structure is retroactive if it allows insertion and removal of operations in the past, and also queries. Informally, is like you went to the past, changed the structure, and the change propagated to the present (like some bad fiction movie).
An usual queue should support modifications enqueue(x), that adds the element x to the end of the queue, and dequeue(), that removes the first element of the queue.
You must deal with the following queries:
All queries are online, that means you should flush the output before reading the input for the following query. Use fflush(stdout) for C/C++.
On the first line, a single integer Q, the number of queries.
Each of the next Q lines have a query, in the format given in the statement.
Limits
For each Q t k query, print its answer.
5
+ 1 E 1
+ 2 E 2
Q 2 1
- 1
Q 2 1
1
2
11
+ 10 E 10
+ 200 E 5
Q 201 1
+ 5 E 1
Q 201 1
+ 7 D
Q 201 2
- 7
Q 199 1
Q 200 2
Q 201 3
10
1
5
1
10
5
On the first sample, 1 and 2 are added to the queue, and then the insertion of 1 is removed.
| Name |
|---|


