You are given a tree with nodes rooted at . The node of the tree has been assigned value . You are required to handle two types of queries:
Input format
Output format
For each query of type , print the number of non-empty subsets of the multiset of values present in a subtree of node when Bob wins.
Constraints
We have . The values on nodes are: . Next, .
The first query is of the type . Consider the multiset of values of nodes present in subtree of node . The multiset is . Consider the subset . Alice starts the game and can reduce it to . Now, Bob cannot reduce it further and so Alice wins. The non-empty subsets of where Bob wins are . Note that is repeated twice because appears twice.
The second query is of the type . We update the value of to . Therefore, the array becomes .
The third query is again of the type . Consider the multiset of values of nodes present in subtree of node . The multiset is . There is only non-empty subset of multiset where Bob wins which is .