There is a grid. Its cells are numbered from left to right. Each cell may be colored or uncolored.
A maximal consecutive interval of colored cells is called a colored component. For a sequence of positive integers
a coloring is valid for if it satisfies all of the following conditions.
Thus, at least one uncolored cell must lie between every two consecutive colored components. If , the only valid coloring has every cell uncolored.
Initially, the sequence is empty. Process the following queries in order.
1 i X: Let the current length of be . Insert between and . If , insert it at the beginning. If , insert it at the end.After each query, find the number of cells that are colored in every valid coloring for the current sequence.
The input is given in the following format.
After each query, print on its own line the number of cells that are colored in every valid coloring for the current sequence.
2 q: Remove the value that was inserted by query from the current sequence.3 W': Change the width of the grid to .Each query has one of the following three forms.
1 i X, if the length of the sequence immediately before the query is , then .2 q, , and query is an insertion query whose value has not been removed yet.| 5 | 38 | No additional constraints. |