You are given a tree T with N nodes rooted at 1. The ith node of the tree has been assigned value Ai. You are required to handle two types of queries:
Input format
Output format
For each query of type 2 v, print the number of non-empty subsets of the multiset of values present in a subtree of node v when Bob wins.
Constraints
1≤N≤5×1051≤Ai≤1061≤u,v≤NGiven edges form a tree1≤Q≤1051≤x≤106
We have N=4. The values on nodes are: A1=1,A2=2,A3=3,A4=3. Next, Q=3.
The first query is of the type 2 1. Consider the multiset of values of nodes present in subtree of node 1. The multiset is S={1, 2, 3, 3}. Consider the subset {1}. Alice starts the game and can reduce it to {0}. Now, Bob cannot reduce it further and so Alice wins. The 3 non-empty subsets of S where Bob wins are {1, 2, 3}, {1, 2, 3}, {3, 3}. Note that {1, 2, 3} is repeated twice because {3} appears twice.
The second query is of the type 1 4 4. We update the value of A4 to 4. Therefore, the array becomes A=[1,2,3,4].
The third query is again of the type 2 1. Consider the multiset of values of nodes present in subtree of node 1. The multiset is S={1, 2, 3, 4}. There is only 1 non-empty subset of multiset S where Bob wins which is {1, 2, 3}.