import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines class SegTree: """ segment tree with point modification and range product access. """ data_unit = 1 << 30 data_f = min def __init__(self, N): self.N = N self.data = [self.data_unit] * (N + N) def build(self, raw_data): data = self.data f = self.data_f N = self.N data[N:] = raw_data[:] for i in range(N - 1, 0, -1): data[i] = f(data[i << 1], data[i << 1 | 1]) def set_val(self, i, x): data = self.data f = self.data_f i += self.N data[i] = x while i > 1: i >>= 1 data[i] = f(data[i << 1], data[i << 1 | 1]) def fold(self, L, R): """ compute for [L, R) """ vL = vR = self.data_unit data = self.data f = self.data_f L += self.N R += self.N while L < R: if L & 1: vL = f(vL, data[L]) L += 1 if R & 1: R -= 1 vR = f(data[R], vR) L >>= 1 R >>= 1 return f(vL, vR) def create_euler_tour(graph, root=1): """1-indexed graph""" V = len(graph) par = [0] * V depth = [0] * V depth[root] = 0 tour = [root] st = [root] while st: x = st[-1] if not graph[x]: st.pop() tour.append(par[x]) continue y = graph[x].pop() if y == par[x]: continue par[y] = x depth[y] = depth[x] + 1 st.append(y) tour.append(y) return tour, depth, par N, K, Q = map(int, readline().split()) C = tuple(map(int, readline().split())) A = list(map(int, readline().split())) graph = [[] for _ in range(N + 1)] lines = readlines() for line in lines[: N - 1]: e, f = map(int, line.split()) graph[f].append(e) tour, depth, parent = create_euler_tour(graph) ind = [0] * (N + 1) for i, x in enumerate(tour): ind[x] = i tour_dep = [depth[v] for v in tour] seg_min = SegTree(K) seg_max = SegTree(K) seg_max.data_f = max seg_max.data_unit = 0 seg_lca = SegTree(N + N - 1) seg_lca.data_unit = None def f(x, y): if x is None: return y if y is None: return x if depth[x] < depth[y]: return x else: return y seg_lca.data_f = f seg_lca.build(tour) def lca(x, y): return seg_lca.fold(x, y + 1) seg_min.build([ind[x] for x in A]) seg_max.build([ind[x] for x in A]) LCA = [] for query in lines[N - 1:]: t, x, y = map(int, query.split()) if t == 2: L = seg_min.fold(x - 1, y) R = seg_max.fold(x - 1, y) v = lca(L, R) LCA.append(v) else: x -= 1 i = A[x] A[x] = y seg_min.set_val(x, ind[y]) seg_max.set_val(x, ind[y]) cost = [0] * (N + 1) for v in tour: cost[v] = max(C[v - 1], cost[parent[v]]) for v in LCA: print(cost[v])