Tree Path
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 128 M,其他语言256 M
64bit IO Format: %lld

题目描述

There is a tree with n vertices and k weighted paths. The following operations are required to be supported:

  • Operation 0: delete the path with the smallest weight in the remaining.
  • Operation 1: given a vertex , ask for the minimum weight among all the weighted paths that do not intersect with .
A path (u,v) intersects with x if and only if x is one of the vertices in the shortest path from u to v (including u and v).

输入描述:

The first line of input contains three positive integers n,k,m (), where m describes the number of operations.
The next n-1 lines each of which contains two positive integers a,b (), representing a tree edge.
The next k lines, each line contains three integers p,q,v (), representing a path with a weight of v. It is guaranteed that the path weights are different from each other.
The next m lines, the first integer of each line describes the type of the operation.
If , then follows an integer u, which describes the vertex of the query as .
last is the answer of the last query operation, and its initial value is 0. is the XOR symbol. It is guaranteed that , .

输出描述:

For each query, output a line with an integer describing the smallest weight.
Output -1 if all weighted paths that have not been deleted intersect the queried vertex or all paths have been deleted.

示例1

输入

复制
5 2 4
1 2
1 3
3 4
3 5
1 3 1
3 5 2
1 3
1 -5
0
1 5

输出

复制
-1
1
2