Task
El Bandito Inofensivo gives a set of words and a stack, you are asked to perform the following operations:
- operation of type : add the character on top of the stack
- operation of type : pop the character from the top of the stack
- operation of type : insert the word in
- operation of type : erase the word from
We say that a word of length is on top of the stack if the suffix (we see the stack as a string, where the last element of the string is the top of the stack) of length of the stack is equal to the string .
If there is a word from the set at the top of the stack, it is removed instantly.
Initially, both the stack and the set of words are empty. You are given operations of the types above and you are asked to print the character on top of the stack after each of the operations. The character on top of the empty stack is considered to be the character .
Input
First line of the input contains the number (). The next lines describe the operations. Each of the lines contain a number , representing the type of operation we have to perform:
- , then the line also contains the character . This line describes an operation of type .
- if , the line describes an operation on type . This operation will never show up when the stack is empty.
- if , then the line also contains the string . This line describes an operation of type .
- if , then the line also contains the string . This line describes an operation of type . This operation will never involve a word which is not in .
For tests worth points, .
For tests worth more points, there is no operation of type and all the operations of type are performed after all the operations of type and .
The sum of lengths of all words inserted in is at most .
The number of operations of type is at most .
It is guaranteed that, at any moment of time, does not contain two words such that one is a suffix of the other.
Output
The only line of the output will contain a string of length , where the character from represents the character on top of the stack after the operation. If after the operation the stack is empty, then the character in will be the character .
Example 1
stdin
10
0 a
0 b
2 bbd
0 b
0 b
1
2 ab
0 d
3 ab
0 b
stdout
abbbbbbaab
Explanation
The evolution of the stack and the set of string after each operation:
After step :
After step :
After step : ,
After step : ,
After step : ,
After step : ,
After step : ,
After step : -> ,
After step : ,
After step : ,