eolymp
bolt
Try our new interface for solving problems
Problems

Brackets

Brackets

The sequence of \textbf{n} opening and closing parentheses are given. You have \textbf{k} queries for changing a single bracket to opposite (the opening bracket changes to closing and otherwise). After each query you must answer does the current sequence of brackets is correct. The bracket sequence is called correct if the number of opening brackets equals to the number of closing, and in any prefix of the sequence the number of opening brackets is no less then number of closing brackets. \InputFile The first line contains \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{100 000}) parentheses. The second line contains the number of queries \textbf{k} (\textbf{1} ≤ \textbf{k} ≤ \textbf{100 000}). Each of the next \textbf{k} lines contains one number \textbf{p} (\textbf{0} ≤ \textbf{p} < \textbf{n}) - the bracket number that must be changed to opposite. \OutputFile Print \textbf{k} lines. In each line print either '\textbf{+}' or '\textbf{--}' depending on the correctness of the current bracket sequence after executing the current query.
Time limit 1 second
Memory limit 64 MiB
Input example #1
()
5
0
0
1
1
0

Output example #1
-
+
-
+
-