This problem will ask you to do some operations on a list. These operations contains insert, remove and show. The position of first node is 0.
The input consist of a number of operations. The first line specifies a non-negative integer N that specifies the number of operations. Each operations (I, R and S) are separated by a newline character (\n).
I stands for “insert”, following by a non-negative integer (insert position, non-negative integer) and a non-negative integer (insert value, 0<=insert value<20). Insert a node at insert position with insert value.
If insert position is greater than or equal to the length of the list, treat the insert position as the next position of the last position at the list.
For example, input is
I 0 0
I 1 1
S
Output should be
0 1
R stands for “remove”, following by a non-negative integer (remove value). Remove the nodes in the list with the value that is equal to remove value.
S stands for “show”. Print the value of all nodes in the list. Separate every prints by a whitespace character. If the list is empty, do not print anything.
For example, input is
2
R 1
S
Output should be nothing.
Print a space after doing S operations (if S has printed something).