- Time limit: 1.00 s
- Memory limit: 512 MB
You are given a rooted tree consisting of nodes. The nodes are numbered , and node is the root. Each node has a value.
Your task is to process following types of queries:
- change the value of node to
- calculate the sum of values on the path from the root to node
Input
The first input line contains two integers and : the number of nodes and queries. The nodes are numbered .
The next line has integers : the value of each node.
Then there are lines describing the edges. Each line contains two integers and : there is an edge between nodes and .
Finally, there are lines describing the queries. Each query is either of the form "1 " or "2 ".
Output
Print the answer to each query of type 2.
Constraints
Example
Input:
5 3 4 2 5 2 1 1 2 1 3 3 4 3 5 2 4 1 3 2 2 4
Output:
11 8