#d257. 序列维护
序列维护
Sequence Maintenance
Problem Description
You have a sequence and need to support several operations:
insert x y: insert the number after the -th element from the front. If , insert at the very beginning.delete x: delete the -th element from the front.query k: ask what the -th element from the front is.
Input Format
The first line contains an integer , the number of operations.
The next lines each contain one of the operations described above.
Output Format
Output several lines: for each query operation, output the answer.
Sample Input
10
insert 0 1
insert 1 2
query 1
query 2
insert 0 3
query 1
delete 1
query 1
insert 1 4
query 2
Sample Output
1
2
3
1
4
Constraints
For of the data, .
For insert operations, .
For all operations, the position is guaranteed not to exceed the current length of the sequence.