A bracket word is a string made up of only two kinds of characters: opening brackets ( and closing brackets ). Among all bracket words we single out the correct bracket expressions: these are the bracket words whose brackets can be matched into pairs so that
Two operations can be applied to a bracket word:
( ↔ ));A sequence of flip and check operations is applied to a bracket word in order. Write a program that reads a bracket word and the sequence of operations from standard input, and for every check operation reports whether the bracket word is a correct bracket expression at that moment.
The first line contains an integer n (1≤n≤30000), the length of the bracket word. The second line contains the n brackets with no spaces between them. The third line contains an integer m (1≤m≤106), the number of operations. Each of the next m lines contains a single integer. If that integer is 0, the operation is a check. If it is an integer p with 1≤p≤n, the operation flips the p-th bracket to the opposite one.
For every check operation, print its result on its own line, in order. Print TAK if the bracket word is a correct bracket expression at that moment, and NIE otherwise. (The number of printed lines equals the number of check operations in the input.)