You are given a directed weighted graph with
n nodes and
2n-2 edges. The nodes are labeled from
1 to
n, while the edges are labeled from
1 to
2n-2. The graph's edges can be split into two parts.
-
The first n-1 edges will form a rooted spanning tree, with node 1 as the root. All these edges will point away from the root.
-
The last n-1 edges will be from node i to node 1, for all 2≤i≤n.
You are given
q queries. There are two types of queries
-
1 i w: Change the weight of the i-th edge to w
-
2 u v: Print the length of the shortest path between nodes u to v
Given these queries, print the shortest path lengths.
Output
For each type 2 query, print the length of the shortest path in its own line.
Example
Output
0
1
4
8
100
132
10