You are given a tree with vertices. The vertices are numbered , and initially vertex has an integer value .
Process the following queries in order. The graph is always a tree while the queries are processed.
0: delete the existing edge and add the edge .1: replace with .2: print the sum of the values of all vertices on the simple path from vertex to vertex in the current tree, including both endpoints.
Input
The input is given in the following format.
For each (), the initial tree has an edge connecting vertices and .
Output
For each query of type 2, print one line containing the sum of the values of the vertices on the specified path in the current tree.
Constraints
- .
- ().
- ().
- The initially given edges form a tree.
- In a query of type
0, , and the edge exists immediately before the query. After deleting and adding , the graph is still a tree. - In a query of type
1, and . - In a query of type
2, . - All numbers in the input are integers.
Subtasks
Samples
The initial vertex values are .
The first output is the sum on the path , which is .
Then the value of vertex becomes . The second output is the sum on the path , which is .
After deleting edge and adding edge , the third output is the sum on the path , which is .
After deleting edge and adding edge , the last output is the sum on the path , which is .