You are given a sequence
representing a parenthesis sequence. When
, it means there is a left parenthesis(in
-th position. When
, it means there is a right parenthesis)in
-th position. There is also a weight sequence
.
For a given parenthesis sequence, you get a unique sequence by deleting substring()until no matching parenthesis left. We call it as the unmatched parenthesis sequence. For example, the parenthesis sequence is)(()(, its unmatched parenthesis sequence is)((, where the position is .
There are operations in three types:
1 x y, change to
, and
to
.
2 l r, For those such that
is an unmatched parenthesis in
, you are asked to calculate the
and
of all
. You only need to output the
of the two results. Assume
and
if there's no such
.
For two unsigned int ,
of them is~(a&b)(in C++ code). For a sequence
,
are computed from left to right. That is,
. The result is
.
3 l r, swap with
, swap
with
.
The first line contains two integers.
Each line of the following n lines contains two integers.
Each line of the following m lines contains an operation :,
,
.
For each of the second operation, output the answer.