Captain America needs to lead his soldiers in his war against the Red Skull. He organized his team in such a way that he can estimate his soldiers’ energy-levels and capacity at any moment, which would help him make crucial decisions as to whom to dispatch to which areas of the war.
He organized his army in the form of a hierarchy - with him as the leader. He set some rules for his war strategy -
In order for Captain to decide whom to send to which area of the war, he designed the following scheme:
You are given the structure of the army, whose size is N, the initial energy-levels of all the individual soldiers, as well the number of queries M. For each query of the type "Q S", report the sum of energy-levels of all the soldiers who have S as their superior.
Note: The soldiers are numbered 1 to N, and Captain is given the number 1.
Input Format:
The first line consists of the integers N and M, denoting the number of soldiers and the number of queries. This is followed by a single line consisting of N nonnegative values - the energy-levels of the N soldiers.
This is then followed by N-1 lines consisting of pairs of integers (u, v), denoting that either u is an immediate superior of v, or vice-versa.
Finally you are given the M queries, of either the form "U S x" or "Q S".
Output Format:
For each "Q S" query, output the sum of energy-levels of all the soldiers under S.
Constraints:
Total number of soldiers is 5 with energy-levels 7, 2, 0, 5, 8. There are 8 queries. According to the relationship 1 is the immediate superior of 2 and 5. 2 in turn is the immediate superior of 3 and 4.
The queries then follow: