#P7865. Jump
Jump
Jump
Problem Description
You are given a rooted tree with nodes, each edge of the tree has a weight, the nodes of the tree are numbered from to , the root of the tree is .
You are also given an array with elements.
Define as the sum of weight of edges on the simple path between and .
Define as the father of node , especially, we define .
There are operations of two types:
1 l r
: for each that satisfies , .
2 l r
: for each that satisfies , output the minimum .
Input
The input contains several test cases, and the first line contains a single integer , the number of test cases. For each test case: The first line contains three integers . For the following lines, each line contains three integers , which means that there is an edge between , the weight of which is . The next line contains integers, the ith integer is . For the following lines, each line contains three integers , which means that there is a operation of type for . , , the weight of edge is an integer in range .
Output
For each operation that , output one line representing the answer.
Sample Input
4
5 1 5
2 5 4
1 5 4
3 2 1
4 2 3
3 4 3 2 5
2 3 3
6 2 1
6 1 1
2 1 1
4 2 3
5 4 2
3 2 1
2 3 6 1 2 6
2 4 6
2 3 3
5 1 5
4 5 3
2 4 2
1 4 2
3 5 3
1 1 5 2 5
2 2 2
5 4 3
2 3 1
1 2 4
5 2 2
4 5 4
1 4 1 1 4
2 2 5
1 1 5
2 2 2
1 1 4
Sample Output
5
0
1
5
5
3
Source
2020 Multi-University Training Contest 9